Learning more about git

From Wiki for iCub and Friends
Jump to: navigation, search

If you are not familiar with git we suggest at least you learn the basics. The official and comprehensive man pages are included in the Git package itself. You can access to them with:

  git --help
  git <command> --help

Quick Git Setup

Setup SSH Keys

You can use git with https, but this requires to insert the username and password every time you need to push on the server (and to fetch or pull if the repository is private). Using ssh will save you some precious time. In order to use ssh you have to create an ssh key and add it to your profile on GitHub.

Your Identity

The first thing you should do is to set your user name and e-mail address.

 git config --global user.name "John Doe"
 git config --global user.email "john.doe@example.com"

Some Color

If you use git mostly from the command line, colors are very useful, you can enable them by running:

 git config --global color.pager true
 git config --global color.ui auto

Bash Prompt

Bash prompt can be tweaked to show you in which branch you are by using __git_ps1. For example you can replace your default prompt in your ~/.bashrc file with:

 if [ "$color_prompt" = yes ]; then
     PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\[\033[00;32m\]$(__git_ps1 " (%s)")\[\033[00m\]\$ '
     PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(__git_ps1 " (%s)")\$ '

Recommended Tutorials

Try git in your browser:


LearnGitBranching - Web application designed to help beginners grasp the powerful concepts behind branching



Git homepage


A few more setup tricks can be found here:


A very comprehensive source of documentation is this:


Git reference:


A Visual Git Reference:


If you are a subversion user, you might find useful this crash course for svn users. Please note that git and svn workflows are slightly different, this is only supposed to be used as reference.


Git documentation wiki (contains several links):


CMake Git resources (more links):


More links:


More tutorials can be found here: