wiki:gittut

LinBox GIT tutorial

Overall principles

  • You work in your branch
  • If you want to use other people's work, take it from their branches
  • If you want everybody to use your modifications, ask the dictator to put them in the master branch

Get your local copy of LinBox-2.0

  • First recovery of the repository (replace dumas by your svn/git name):
    > git clone ssh://dumas@linalg.org/linbox.git
    
  • This creates a "linbox" directory under the current directory.
  • Local creation of the user's branch for the server's master branch:
    > cd linbox
    > git branch --track jg/master origin/master
    
  • Show your local copies of the existing branches, plus the ones stored on the server (prefixed by "origin"),

the branch marked by a star is the branch corresponding to the files you currently have:

> git branch -a
* master
  jg/master
  origin/HEAD
  origin/master
  origin/pernet/master
  ...
  • You cannot work in the master branch (only the LinBox dictator-for-life can), so you switch to your branch:
    > git checkout jg/master
    Switched to branch "jg/master"
    > git branch -a
      master
    * jg/master
      origin/HEAD
      origin/master
      origin/pernet/master
      ...
    
  • Copy your branch to the server so that it will be backed up on the server:
    > git push origin jg/master
    * [new branch]          jg/master  --> jg/master
    

Common Usage

  • Recover the changes in your working branch from the server:
    > git pull
    
  • Commit all your local changes to your local working branch:
    > git commit -a
    
  • Backup your commited changes to the server:
    > git push
    
  • What is your working branch status:
    > git status
    
  • Show the modifications made to a file:
    > git log file
    commit f47e2020cee0ae8abe665cc6db638988a4277b2b
    Author: U-Cyclone\jgdumas <Jean-Guillaume.Dumas@imag.fr>
    Date:   Fri Dec 11 14:17:48 2009 +0100
    
        My very important modification
    
  • Show the differences between a file and a specific commit (you just need the first 6 digits of the hash):
    > git diff f47e20 file
    diff --git a/file b/file
    index 198bd53..7f5bb40
    
    - ...
    + ...
    
    

Updates

  • Recover locally the modifications of the different branches:
    > git fetch
    
  • See what modifications have been made:
    > git log --all
    
  • Apply the modifications of a given branch to your local working branch:
    > git merge origin/pernet/master
    

Push your modifications to the master branch

  • Open a new ticket
    • with a patch
    • with a commit id and local branch name
    • with a local branch

Anonymous recovery

> git clone git://linalg.org/home/www/var/git/linbox.git

References

Equivalences between SVN and GIT  http://git.or.cz/course/svn.html

Git mini how-to  http://pacific.mpi-cbg.de/wiki/index.php/Git_mini_howto