I’m not too fond of terminals. This guide is for new GNOME contributors like me whose brain capacity for terminal commands is only so-so big. I will introduce you to 8 git commands worth remembering. I assume only vague familiarity with git: pulling, pushing and committing.
In GNOME you need to
- keep your commits clean.
- let your commits go through GNOME’s bugzilla as a patch.
- make modifications to your commits based on feedback.
To do this, first, start doing your work in local branches. A branch is like doing a Save-As of your current git project including history and everything. The branch is independent and you can freely jump back and forth between “master” and your own branch.
Create a branch:
git branch yourname/yourbranch
Open a branch:
git checkout yourname/yourbranch
Delete a branch:
git branch -D yourname/yourbranch
Okay. Now, you have done your work and you need to file a bug on bugzilla. Commit your work with a max 80 character commit message and then make a
*.patch you can upload.
git format-patch HEAD^
(creates a patch from your latest commit.)
Soon you receive an e-mail saying someone reviewed your patch, and they tell you to make some changes. So you make the changes and now you want to put them into your existing commit. You do this by first doing
git add , and then do:
git commit --amend
(modifies your commit to include your changes.)
You can then create a patch from your commit again and upload your new work to bugzilla. Remember to mark the old patch as obsolete in there.
Let’s say you need to test someone else’s patch then. To do this you can do a:
git am mypatch.patch
(applies a patch to the top of your branch.)
This will apply a patch named
mypatch.patch to your git folder. If you want to revert back to how it was before, then you can do:
git reset --hard HEAD^
(reverts the top commit of your branch.)
This will revert the latest commit so be careful. Work on a copy branch so you safely can mess around. There’s no easy ctrl+z here. You can run this reset command several times to go several commits back in time. You can keep track of where you are with:
(shows the 5 latest commits on your branch.)
..and that’s it. I think this is everything you need to know to start contributing small patches to your favorite FOSS project. You can revert, copy, create and modify patches. Never be afraid of filing bugs, especially when you attach a patch to them. :)