Skip to main content

Committing changes to a pull request branch created from a fork

Commit changes to a pull request branch created from a fork by obtaining the necessary permissions and using Git commands effectively.

To commit to a pull request branch created from a fork, you need push access to the base repository, permission from the pull request creator, and a user-owned fork without branch restrictions that prevent your push. Only the pull request creator can allow edits to their fork. See Allowing changes to a pull request branch created from a fork.

  1. On GitHub, navigate to the fork where the pull request branch was created.

  2. Above the list of files, click Code.

    Screenshot of the list of files on the landing page of a repository. The "Code" button is highlighted with a dark orange outline.

  3. Copy the URL for the repository.

    • To clone the repository using HTTPS, under "HTTPS", click .

    • To clone the repository using an SSH key, including a certificate issued by your organization's SSH certificate authority, click SSH, then click .

    • To clone a repository using GitHub CLI, click GitHub CLI, then click .

      Screenshot of the "Code" dropdown menu. To the right of the HTTPS URL for the repository, a copy icon is outlined in dark orange.

  4. Open your terminal or Git Bash.

  5. Change the current working directory to the location where you want to clone the fork.

    cd open-source-projects
    
  6. Clone the fork, then navigate into the cloned repository.

    git clone https://github.com/USERNAME/FORK-OF-THE-REPOSITORY
    cd FORK-OF-THE-REPOSITORY
    
  7. Check out the pull request's compare branch. To find the compare branch, open the pull request and check the branch shown at the top of the page.

    git checkout TEST-BRANCH
    
  8. Make your changes, then stage and commit them.

    git add .
    git commit -m "YOUR-COMMIT-MESSAGE"
    
  9. Push your commit to the pull request branch.

    git push origin TEST-BRANCH
    

Your new commits appear on the original pull request on GitHub.com.

Further reading