How to create good merge requests with Gitorious
We use Gitorious as a collaboration tool that allows everyone to have their own clones of Jambi publicly visible and maintained by Gitorious under our project, browse easily commits, source repositories and other repository related material available there.
It also allows everyone to submit official merge requests(later MR) of their own modifications so that we can comment them and apply them either as-is or modified. Even as those commits are not directly thrown as-is in but rather as a merge, ownership of the modification is creator of the MR, not the one who happened to actually do the review and merge of the MR.
Below basic guidelines of how to do good merge requests.
Qt Jambi’s git repositories are hosted at Gitorious, so ﬁrst of all you need to create your
personal account at gitorious.org. After you did it is
time to make a ssh key known to Gitorious (Gitorious explains how to) and to create your
personal clone of the
To do so, visit qtjambi-community and click Clone repository. Before you can work within your personal repository, you have to get a working copy (replace user by your username):
git clone email@example.com: user/qt-jambi/users-qtjambi-community.git
If authentication fails, your public key may be protected, so it requires some steps to get it available. When you open your private key, it may contain words like
which implies that the key is protected. Instructions for adding the key to the agent below.
- Add your ssh key with
ssh-add /.ssh/jambi rsa
- start ’ssh-agent’ next to it.
You’re now able to work on your local copy.
As freshly checked out, there is only the master branch. You should leave this branch clean as it is technically owned by the upstream project. One of the clean ways (there are many ways to deal with git, but this the one I use) is to create one branch per merge request you want to create:
git checkout -b yourbranch master
You can list local branches with first command and remote branches with second one:
git branch git branch -r
Toggling between branches can be done with
git checkout yourbranch, the -b op-
tion creates a branch if not existing. The yourbranch is only created at your local host
and not known to your gitorious repository. To make it known to gitorious do
git push origin yourbranch
Now you make your changes and commit them with
git commit. To push them to
your gitorious repo do
Your changes are now also in your gitorious clone of the qtjambi-community repository and you can create your merge request.
Create a merge request
A merge request can be created at Merge request creation page. If you are in your repository you can click on Request merge to get to this side.
Next please fill in the Summary (I usually take my git commit comment) and enter some additional information on what the commits you would like to merge do.
Select target and source branch and the recent commit and create your merge request
More about Git
To get the latest upstream changes to your repository you first have make the extern repository known to git. This happens with
git remote add upstream git://gitorious.org/qt-jambi/qtjambi-community.git
Next you can fetch changes form upstream and merge them to your local master
git fetch upstream && git checkout master && git rebase -i upstreammaster
If the rebase commit message says ’noop’ everything is ﬁne. Else resolve conﬂicts, for example with git mergetool.
Then you can push all changes to your master branch with:
git push origin master
Now you’re working on the latest upstream sources.
If have for example three different branches with changes and want to make one test build including all your modiﬁcations, this can be done by merging them together into one branch:
git checkout -b master build master && git merge yourbranch1 && git merge your-branch2 && git merge yourbranch3 && ant all
After your done, get it clean again and delete the master build branch:
git checkout master && git branch -d master build
This text has been contributed by Marius Brehler and modified to suit the website by Samu Voutilainen along with minor changes. If you have a suggestion or have your own text you’d like to see at our site, please contact us.