Sometimes we just need to feed the SEO gods… in this case, I could not find the simple git command line to update a pull request that I had in flight.
I was looking for the following:
git push -f personal HEAD:[pull branch]
Github.com happily gave me instructions from the pull branch but not the CLI version of the command. The trick is that you need to know your remote (git remote) for the command so it’s not perfectly generic. In the example above, my personal repo is named “personal”.
Deconstructing the command: you are pushing your to your personal clone from the local HEAD commit against the branch created for the pull request. That’s because the pull request creates a branch from your clone to be pulled into the upstream repo. That’s why it’s a PULL request not a push.
Ultimately, this is pretty basic git. My experience with git is that the definition of “pretty basic” is a binary function. Once you know how git works, everything in git is pretty basic. Until then it’s completely opaque.
Side note: this is my 301st post on this blog!
8/1/2013 Post Script from Crowbar Contributor Adam Spiers
He noticed that I should include the -f in the git push instruction. Read more at about that on his blog.
Yes, using the -f switch to git push is usually a very good idea when updating pull request branches. This is due to the clarity it lends to github’s review process, which is not perfect but still more featureful than most people realise. I go into more detail about that on my blog (see link in the P.S.)
Of course, the benefits of -f only come into play when the pull request history is polished via git rebase -i or similar. But everyone should be doing that as a normal matter of habit 🙂
A great alternative is go use git-pull-request that does everything for you: