跳到主要内容

Pushing a Commit to an Existing PR

To push a commit directly to a PR created by someone else:

信息

Before following the instructions given on this page, ensure that the PR has enabled Allow edits from maintainers.

  1. Check out the PR using gh:

    gh pr checkout <pr-url>
  2. Make your changes locally.

  3. Commit your changes:

    git commit -am "commit-message"
  4. Add the PR owner's repo as remote:

    git remote add <pr-owner> https://github.com/pr-owner/repo-name.git
  5. Fetch its current content:

    git fetch <pr-owner>
  6. Push your commit to the branch:

    git push <pr-owner> <branch-name>

After this, you can go back to the PR's page on GitHub and refresh the page. You should find the commit you just pushed.