Skip to content

Git commit policy

nilsbecker edited this page May 10, 2011 · 5 revisions

The workflow described here is outdated, see git workflow instead. Keeping it for now for possibly useful tricks

This article files the current Git commiting policy of our project. The policy is also written down in the file DEVELOPMENT in the main directory of the repository.

Committing changes

  1. $ git checkout common-develop
  2. $ git pull (Updates common-develop to the latest version of origin/develop.)
  3. $ git branch someNewFeatureBranch (Creates a nice clean branch for you to work on.)
  4. [edit edit]
  5. $ make check (Runs tests to see if you didn’t break anything.)
  6. $ git add <files_that_contain_changes_that_you_want_to_commit> (Adds the changes from these files to the staging area.)
  7. $ git commit (Commits only the changes from the staging area, not any other changes you also made. That’s the power of git for you right there.)
  8. Write a nice commit message. This requires using vim. Start with presssing i, save and exit with :wq.

If you prefer to reuse an existing local development branch, and you are sure it does not contain unwanted commits or changes, then replace step 3. by:

3a. $ git checkout yourLocalDevelopmentBranch
3b. $ git rebase common-develop (This pulls in new commits from common-develop and replays any local commits you had here on top of it.)

Sharing changes

  1. Email Laurens (bossenATamolf.nl) with a pull request. Specify url or directory (at Amolf) and branch (someNewFeatureBranch).
  2. Wait till Laurens has merged your changes into origin/develop.
  3. $ git branch -d someNewFeatureBranch (Deletes someNewFeatureBranch again. Will refuse if you have commits here that are not also in a different branch, so safe.)

Sharing changes if you know how to solve possible merge conflicts

  1. $ git checkout common-develop
  2. $ git pull (Updates common-develop to the latest version of origin/develop.)
  3. $ git checkout yourLocalDevelopmentBranch
  4. $ git rebase common-develop (This pulls in new commits from common-develop and replays your new commits on top of it.)
  5. Solve any merge conflicts.
  6. $ make check (Runs tests to see if you didn’t break anything.)
  7. Email Laurens (bossenATamolf.nl) with a pull request. Specify directory and branch.
  8. Wait till Laurens has approved your changes and merged them into origin/develop.

Extras

  1. $ git config --global core.editor <your editor of choice> (Specifies which editor to use for commit messages. vim by default.)
  2. $ git config --global color.diff always (Makes git diff nicely colored.)
  3. Add this to your .bashrc (Sets your bash prompt to show which branch you are in, only if you are in a git repository):

    if [ -f /etc/bash_completion.d/git ]; then
    source /etc/bash_completion.d/git
    export PS1=’\W$(__git_ps1 “(%s)”)$ ’
    fi

    Note that the single and double quotes are the ones next the enter on the keyboard, otherwise it will not work.
  1. If you prefer to use Mercurial over Git see the Hg-Git mercurial plugin

References

  1. http://git-scm.com/
  2. http://gweezlebur.com/2009/01/19/my-git-workflow.html
  3. http://nvie.com/archives/323