Rebasing finished pull requests (was: Notes, November 25)

On 25/11/2015 17:30, Harald Alvestrand wrote:
> I thought you could only rebase when you had write access to the
> *source* repo (the one the original PR is merging from)?

That is correct if you want to update the PR itself [I've been meaning 
to propose a way around that limitation in github, but that's for 
another thread].

But in this case, what we want is to merge the PR, so updating the PR 
itself is no longer useful (we assume it has been reviewed and agreed 
upon). In that case, the editors can:
* fetch the content of the PR branch
* rebase it locally
* merge it onto master

To fetch a remote PR, I have this following alias in my global git 
config (~/.gitconfig in my setup):
[alias]
         pr = !git fetch -fu ${2:-origin} refs/pull/$1/head:pr/$1 && :

once that is configured, "git pr XXX" will fetch the content of the PR 
#XXX and make it available as a local branch named pr/XXX; using that 
alias is obviously not required, but it's probably a useful shortcut.

So in more details, to rebase and merge PR #XXX (assuming master is up 
to date):
* git pr XXX
* git checkout pr/XXX
* git rebase master
[git add / git rebase --continue as needed]
* git checkout master
* git merge pr/XXX
* git push origin master

(off the top of my head)

Dom

Received on Wednesday, 25 November 2015 16:43:51 UTC