Git Howto

From HallCWiki
Jump to: navigation, search

From the git homepage:

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

Git is easy to learn and has a tiny footprint with lightning fast performance. It outclasses SCM tools like Subversion, CVS, Perforce, and ClearCase with features like cheap local branching, convenient staging areas, and multiple workflows.

Git is similar to CVS, SVN, etc. but the cheap local branching make it feasible to use a very powerful workflow where you can checkout, try something, backup, test something different, switch back to attempt 1 -- all without losing any of your work. You can also easily merge between these different branches and push-pull pieces of commits from others. It is ideal for the kind of highly distributed development we do at JLab.


Some general links to help users come up to speed with git.

Git Tutorials/How-tos

Git Workflows

Tweaks:

  • Add the current git branch and status to your bash prompt
    • Save git-prompt.sh to '~/bin/git-prompt.sh' under your account
    • Edit your ~/.bashrc file and add this line somewhere towards the end
 [ -r ~/bin/git-prompt.sh ] && source ~/bin/git-prompt.sh
  • Add the current git branch and status to your csh/tcsh prompt (see Note[1] below).
    • Save gitprompt.pl to '~/bin/gitprompt.pl' under your account
    • Edit your ~/.cshrc (or ~/.tcshrc) file and add these lines somewhere towards the end
 if ( $?prompt && -x /usr/bin/git && -x $HOME/bin/gitprompt.pl ) then
   alias precmd $HOME/bin/gitprompt.pl
 endif

NOTE[1]: If you are on a CUE machine you may need to change '/usr/bin/git' to '/apps/bin/git' in the above lines AND in the gitprompt.pl script.

NOTE[2]: These call 'git status' to generate the prompt and so can cause the shell to stall for a short period if the git metadata isn't cached. I only find this delay noticable for really big repositories like the linux kernel. Once the git info is cached, (ie. after the first longish delay) the prompt returns very quickly again.


NOTE: If you find a resource that you really appreciate. PLEASE ADD IT TO THE LIST!