Nice settings for Git

To configure git, you can either use the git config --global KEY VALUE command or manually edit ~/.gitconfig.

Tell git who you are:

git config --global "FirstName LastName"
git config --global ""

To enable auto-detection for number of threads to use (good for multi-CPU or multi-core computers) for packing repositories, use:

git config --global pack.threads 0

To disable the rename detection limit (which is set "pretty low" according to Linus, "just to not cause problems for people who have less memory in their machines than kernel developers tend to have"), use:

git config --global diff.renamelimit 0

To automatically detect when a local branch is connected to a remote branch (the --track option of git branch):

git config --global branch.autosetupmerge true

Or, to turn all color options on (with git 1.5.5+), use:

git config --global color.ui auto

Setup some nice aliases:

git config --global commit
git config --global checkout
git config --global status
git config --global alias.df diff

To get the code in the ancestor in merge conflicts (in addition to the two version being merged):

git config --global merge.conflictstyle diff3

You can get more nice options in $ cheat git. There are also nice tricks to be learnt at git ready.

Setup ssh for Git

First, configure ssh so it connects to alioth with the correct username. Modify ~/.ssh/config to have something like:

    User aliothname-guest

You don't need to type your password every time. You can setup ssh keys. In order to do that, you need to have generated ssh keys. If you have a file named ~/.ssh/id_rsa or ~/.ssh/id_dsa with the matching or, you have generated your keys. if not, just run ssk-keygen and accept the default choices.

Now, you have to tell alioth of your public keys, just run:

cat ~/.ssh/*.pub

And paste the result in the field reserved for it in your alioth user account.

Lisaac Git Repositories

All the alioth git repositories are to be found in the alioth git page, just search for the string lisaac/.

To get your copy of the git repositories, you can just run:

git clone git+ssh://
git clone git+ssh://
git clone git+ssh://
git clone git+ssh://
git clone git+ssh://
git clone git+ssh://
git clone git+ssh://
git clone git+ssh://
git clone git+ssh://
git clone git+ssh://
git clone git+ssh://
git clone git+ssh://
git clone git+ssh://
git clone git+ssh://
git clone git+ssh://
git clone git+ssh://

You can find more information about some of these repositories:

Git Tools

gitk is a graphical tool that let you view the history of the repository and what happened at each commit.

git gui or git citool is a graphical interface to git add and git commit. With it you can easily commit the changed files in your working directory. It is very useful if you want to be very specific in what you commit and what you don't. For example, you can commit only some files and leave other uncomitted. or even choose which lines in a file you ant to commit.

Git Commands

  • git checkout: checkout a specific revision or a specific branch. Modify your working copy.
  • git add: mark files to be comitted.
  • git status: see what you are about to commit
  • git commit: commit files you marked with git add
  • git commit: commit all modified files
  • git rm: remove a file from the repository
  • git mv: move a file in the repository
  • git diff: see the modifications you won't be comitting
  • git diff --staged: see the modifications that are about to be comitted
  • git pull: merge your local branch with a remote repository
  • git push: push your modifications to a remote repository
  • git stash: tempoary store the modifications you made for later use (read the help)

Git branches

Branches in git can either be local or remote. Local branches is where you work, and remote branches keep track of the branch of foreign repositories. The repository you cloned is generally called origin, hence all the branches of this repository will be prefixed by origin/.

Even if they are called remote branches, no operation on them require an internet connexion, except when you want to synchronize them with the remote repository.

You can view your local branches using:

git branch

And you can see remote branches using:

git branch -r

When you clone the repository, only the main branch (usually called master, but it may be different for some repositories) will be imported as a local branch.

If you want to work on a specific branch, you must have a local branch to represent it. To create a local branch you can use:

git checkout --track -b branchname origin/branchname

Import the remote changes in the local repository

Since there are local and remote branches, you might want to * either update the remote branches, this won't change your local branches and your work, * or update the remote branches and the local branches that correspond to them. This might perform a merge to resolve conflicts.

For the first option, just run:

git fetch

If you want to update your local branches as well (and risk a merge):

git pull

You might want to rebase instead of merge (read the rebase sectionb below). Then you would write:

git pull --rebase

Or you can run git fetch and then merge manually using:

git merge origin/branchname

Push your changes on the remote repository

For the push to work, you need to have your local branch up to date with the latest commit on the remote repository. A git pull will do nicely. Then you can just run:

git push


Rebasing is a feature of git that let you have a cleaner history. Instead of having different branches you merge, the history will be linear without merge. having a linear history makes it easier to read and easier to detect where a bug was introduced.

Rebasing is great but has a major drawback. It remove your old commits and rewrite them. So, the commit identifier (sha-1) changes. As a consequence if you published your work and someone used what you did, this might create problems. So, as a general rule, dont rebase when you published your changes (pushed them).

Rebase works just as git merge, but instead you write git rebase. For example you can do:

git rebase origin/branchname

to have all the new commits on the current local branches be applied on top of the latest commit on the remote branch branchname.

You can also tell git pull to perform a rebase instead of a merge:

git pull --rebase

Interactive rebase

You can reorder the commits you bade using interactive rebase. Just use git log or gitk to identify the sha-1 of the oldest commit you ant to change and run:

git rebase -i commit-identifier

It will pop up an identifier, and you can reorder the commits as you want. There are also other options you might want to discover.