Skip to content

Latest commit

 

History

History
96 lines (74 loc) · 5.3 KB

committing-changes-to-a-pull-request-branch-created-from-a-fork.md

File metadata and controls

96 lines (74 loc) · 5.3 KB
title intro redirect_from versions topics shortTitle
Committing changes to a pull request branch created from a fork
You can commit changes on a pull request branch that was created from a fork of your repository with permission from the pull request creator.
/github/collaborating-with-issues-and-pull-requests/proposing-changes-to-your-work-with-pull-requests/committing-changes-to-a-pull-request-branch-created-from-a-fork
/articles/committing-changes-to-a-pull-request-branch-created-from-a-fork
/github/collaborating-with-issues-and-pull-requests/committing-changes-to-a-pull-request-branch-created-from-a-fork
/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/committing-changes-to-a-pull-request-branch-created-from-a-fork
fpt ghes ghec
*
*
*
Pull requests
Commit to PR branch from fork

You can only make commits on pull request branches that:

  • Are opened in a repository that you have push access to and that were created from a fork of that repository
  • Are on a user-owned fork
  • Have permission granted from the pull request creator
  • Don't have branch restrictions that will prevent you from committing

Only the user who created the pull request can give you permission to push commits to the user-owned fork. For more information, see "AUTOTITLE."

Note

You can also make commits to a pull request branch from a fork of your repository through {% data variables.location.product_location %} by creating your own copy (or fork) of the fork of your repository and committing changes to the same head branch that the original pull request changes were created on. For some general guidelines, see "AUTOTITLE."

  1. On {% data variables.product.product_name %}, navigate to the main page of the fork (or copy of your repository) where the pull request branch was created. {% data reusables.repositories.copy-clone-url %} {% data reusables.command_line.open_the_multi_os_terminal %}

    [!TIP] If you prefer to clone the fork using {% data variables.product.prodname_desktop %}, then see "AUTOTITLE."

  2. Change the current working directory to the location where you want to download the cloned directory.

    cd open-source-projects
  3. Type git clone, and then paste the URL you copied in Step 3.

    git clone https://{% data variables.product.product_url %}/USERNAME/FORK-OF-THE-REPOSITORY
  4. Press Enter. Your local clone will be created.

    $ git clone https://{% data variables.product.product_url %}/USERNAME/FORK-OF-THE-REPOSITORY
    > Cloning into `FORK-OF-THE-REPOSITORY`...
    > remote: Counting objects: 10, done.
    > remote: Compressing objects: 100% (8/8), done.
    > remove: Total 10 (delta 1), reused 10 (delta 1)
    > Unpacking objects: 100% (10/10), done.

    [!TIP] The error message "fatal: destination path 'REPOSITORY-NAME' already exists and is not an empty directory" means that your current working directory already contains a repository with the same name. To resolve the error, you must clone the fork in a different directory.

  5. Navigate into your new cloned repository.

    cd FORK-OF-THE-REPOSITORY
  6. Switch branches to the compare branch of the pull request where the original changes were made. If you navigate to the original pull request, you'll see the compare branch at the top of the pull request.

    In this example, the compare branch is test-branch:

    git checkout TEST-BRANCH

    [!TIP] For more information about pull request branches, including examples, see "AUTOTITLE."

  7. At this point, you can do anything you want with this branch. You can push new commits to it, run some local tests, or merge other branches into the branch. Make modifications as you like.

  8. After you commit your changes to the head branch of the pull request you can push your changes up to the original pull request directly. In this example, the head branch is test-branch:

    $ git push origin test-branch
    > Counting objects: 32, done.
    > Delta compression using up to 8 threads.
    > Compressing objects: 100% (26/26), done.
    > Writing objects: 100% (29/29), 74.94 KiB | 0 bytes/s, done.
    > Total 29 (delta 8), reused 0 (delta 0)
    > To https://{% data variables.product.product_url %}/USERNAME/FORK-OF-THE-REPOSITORY.git
    > 12da2e9..250e946  TEST-BRANCH -> TEST-BRANCH

Your new commits will be reflected on the original pull request on {% data variables.location.product_location %}.

Further Reading