You know how all merge requests on Gitorious are Git "branches", right? Merge requests can be pulled, merged, cherry-picked just like any other Git ref. But you probably knew that right?
Inspired by (blatantly stealing from is more like it) this Gist it
dawned on me that I should start having all merge requests to my
repositories pulled down whenever I do a
git fetch as well, so
I'll add this to my
[remote "origin"] fetch = +refs/heads/*:refs/remotes/origin/* url = firstname.lastname@example.org:gitorious/mainline.git fetch = +refs/merge-requests/*:refs/remotes/origin/merge-requests/*
This means that any ref in
refs/merge-requests/* should be fetched into a local "ref stub"
origin remote as a normal branch. So whenever I do a
git pull I'll see something like this
From gitorious.org:gitorious/mainline 2f57987..6a00848 master -> origin/master * [new ref] refs/merge-requests/100 -> origin/merge-requests/100 * [new ref] refs/merge-requests/101 -> origin/merge-requests/101 * [new ref] refs/merge-requests/102 -> origin/merge-requests/102 * [new ref] refs/merge-requests/106 -> origin/merge-requests/106 * [new ref] refs/merge-requests/107 -> origin/merge-requests/107 * [new ref] refs/merge-requests/1074 -> origin/merge-requests/1074
One line for each merge request in the repository.
You know how it's really annoying when you want to check out a
local branch tracking a remote branch by the same name and the
remote branch already exists? First create the local branch, then
pull from the remote one and enter
git help pull to find which
switch to use to set up tracking. Assuming you have a remote branch
named topic-1, you can simply enter
git checkout feature-1 Branch feature-1 set up to track remote branch feature-1 from origin. Switched to a new branch feature-1'
Now that's a powerful hidden gem right there. How about combining this with the automatically fetched merge requests?
git checkout merge-requests/95 Branch merge-requests/95 set up to track remote branch merge-requests/95 from origin. Switched to a new branch 'merge-requests/95'
One simple command which brings you right into review mode. Whenever you're happy with what you see, jump back into master, merge & pull
git checkout master git merge merge-requests/95 git push