Skip to content

A quick git guide for people who want to make contributions to Voldemort

Sid Wu edited this page Jan 28, 2016 · 3 revisions

A quick git guide for making contributions to Voldemort

Voldemort is an open source distributed database based on Amazon Dynamo. As we keep striving to improve its features, we are pleased that you are interested on Voldemort and would like to contribute to it. It is currently on our Voldemort github page. Feel free to fork it to your own repository and start your own exploration. Here are some quick git tips on how to work on Voldemort and merge your patches to our Voldemort project.

If this is the first time, clone your forked repo into the local machine.

git clone git@github.com:[your_github_account]/voldemort.git
cd voldemort

Then, add the main Voldemort repo as a remote node in your local git setting.

git remote add voldemort git@github.com:voldemort/voldemort.git
git remote -v

Make sure your code is up-to-dated every time before you start to work.

git checkout master
git pull --rebase voldemort master

For most of the cases, we advise you also to make a new branch before you start working. This helps keep your master from being dirty. Here we create a new bug-fix-branch. Ideally, please try to choose a relevant branch name.

git checkout -b bug-fix-branch

Once your work is done, make sure to add them to the git index so that they are ready to be committed.

git add [path_to_file]
# Or use a dot if you want to commit all the files you have modified.
git add .

You could also double check your codes before they are committed by diff.

git diff --cached

Make a commit. It will open an editor for you to add comments.

git commit
# Or with the -a option if you want to skip 'git add' and 'git diff', and commit all of your modified files.
git commit -a

The next step is to push your commit to your github repo. The code below would push your commit to the branch you point out in your github repo.

git push [your github repo] [branch name]

for example:

git push origin bug-fix-branch

Once you have done all the above, don't forget to log into your github page and create a pull request for your commit. We will be pleased to see your contributions and start to review your codes. We will merge your patch into Voldemort when code review is done.

Notice that you may need to repeat the above steps if we would like you to change your codes while reviewing your code. Though it could be a tiny change, it does require you to re-commit your code. This procedure maintain Voldemort neat and efficient but kind of pollute git version control system since it tracks whatever commit and add all of them to the version line. Therefore, in order to keep a clean version control history, we would like you to squash your commits.

git rebase -i HEAD~[number]

where [number] is the amount of commits you have made during the code review.

Git will open an editor and you can see all of your commits. By replacing the 'pick' in front of each commit to 'squash' allows you merge the current commit to its previous one. (Notice: don't 'squash' all of your 'pick', since it will revert your code.)


pick 5e598b7 commit 2
pick eb9a4f0 commit 3
# Rebase 33f90cc..eb9a4f0 onto 33f90cc (2 command(s))
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out

You should then amend your commit message so that it's not a jumbled bunch of incremental changes. This can be achieved by amending your last commit, which will open a text editor where you will have the opportunity to edit the commit message.

git commit --amend

In order to write a good commit message, please follow the following guidelines:

  1. Your first line should be short. This is so that it fits in the GitHub's UI without being truncated.
  2. On the second and subsequent lines, describe the problem that this commit intends to solve, and how the commit solves that problem.
  3. Keep your line lengths short so that, again, the formatting looks good when browsing commits on GitHub.