How to update an existing pull request with its id

Viewed 521

I am new to github and I know it is a very basic question but i don't know what to do. I saw some youtube videos and some github questions but could not understand them

I created a pull request and it had some changes to be made so I made the required changes and actually created one more pull request instead of updating the original PR.

Lets say the previous PR was #100 and the new PR is #101 how can I change or update the #100 PR?

Answer with all the git commands would be helpful, thanks

1 Answers

That's actually pretty easy.

First you need to know the branch name for the pull request that you opened, go to https://github.com/owner-username/repo-name/pull/100

and the header should say something like your-username wants to merge 1 commit into owner-username:master from your-username:patch-1

patch-1 or something else is your branch name for the 100-th pull request.

Now you just need to switch to that branch(in your local copy of it, in a fork):

git checkout patch-1

Add new commits to it, or adjust existing ones and push to your own fork:

git commit --allow-empty -m "This is another commit in my pull request"
git push origin patch-1

Your original pull request would be instantly updated because it's just a reference to your fork with a specific branch name.

Upd. you can open pull requests to your own repository, in this case you don't need to fork it(you can't).

Related