Перейти к содержанию

Editing or Changing the Title of an Existing Pull Request via CLI

Introduction

This Gemstone explains how to edit or change the title of an existing pull request (PR) in a GitHub repository using both the GitHub web interface and CLI.

Problem Description

Sometimes, the title of a PR after its creation may need to be modified to better reflect the current changes or discussions.

Prerequisites

  • An existing GitHub pull request.
  • Access to GitHub web interface or CLI with necessary permissions.

Procedure

Using the GitHub CLI

  1. Check Out the Corresponding Branch:
  2. Ensure you are on the branch associated with the PR.

    git checkout branch-name
    
  3. Edit the PR Using the CLI:

  4. Use the following command to edit the PR:

    gh pr edit PR_NUMBER --title "New PR Title"
    
  5. Replace PR_NUMBER with the number of your pull request and "New PR Title" with the desired title.

Additional Information (Optional)

  • Editing a PR title will not affect its discussion thread or code changes.
  • It's considered good practice to inform collaborators if significant changes are made to a PR title.

Conclusion

Following these steps, you can easily change the title of an existing pull request in a GitHub repository through the GitHub CLI tool (gh).

Author: Wale Soyinka

Contributors: Ganna Zhyrnova