Laurent Menut - GIT commands

Initialize repositories
  1. Create your remote repository from the root (= trunk) repository
    git clone --bare newcalcul:/ws3/pollux/CHIMERE/chimereRoot/ /data/PLT6/pub/user/MyChimereGit
  2. create your local repository from your remote one on /data/PLT6/pub; its name will be chimere
    ssh chims-n2
    cd mychimere
    git clone /data/PLT6/pub/user/MyChimereGit chimere
  3. to follow the trunk repository (= to be able to synchronize with it)
    cd chimere
    git remote add -f trunk newcalcul:/ws3/pollux/CHIMERE/chimereRoot/
    gitk --all &

Develop, commit and submit your changes
  1. create your branch for specific developments
    git checkout -b my_branch
  2. switch between branches
    git checkout another_branch
  3. Check if actions are pending
    git status
    git status -uno (to see followed files only)
  4. develop and update your own local branches
    git add routine_names
    git commit (and document your changes in the text file)
    gitk --all
  5. to see what's going on in remote repositories (those added with the "git remote add" command)
    git fetch --all
  6. get the new developments from the trunk to your master branch and resolve conflicts if there
    git checkout master
    git pull trunk master
  7. get developments from your local my_branch branch to your local master branch
    git merge my_branch
    or
    git cherry-pick (SHA-1 modif 1)
    .....
    git cherry-pick (SHA-1 modif N)
  8. Put those changes to your remote repository
    git push origin MyBranch
  9. Move your development branch directly to the devel branch (SHA-1)
    git reset --hard (SHA-1)
    git push -f origin my_branch
  10. Rename a local branch:
    git branch -m [new_name]
  11. Delete a local branch:
    git branch -d [to_delete]
  12. Delete a remote branch:
    git push [remote_name] --delete [branch_name]
  13. Put your devel branch to the depot_root level. Move your changes from your local working branch my_work to your local devel branch.
    git checkout devel
    git pull depot_root/devel
    git checkout
    git rebase devel

    then resolve conflicts
    git rebase --continue
    Use kdiff3 for differences between branches
    1. Create an executable script file named ~/scripts/git-diff-wrapper.sh
    2. Put in the script the following code:
      #!/bin/sh
      # diff is called by git with 7 parameters:
      # path old-file old-hex old-mode new-file new-hex new-mode
      "/usr/bin/kdiff3" "$2" "$5" | cat
    3. Add this line in your GIT config file, named ~/.gitconfig
      [diff]
      external = ~/scripts/git-diff-wrapper.sh
    4. You can now see differences between two branches, for all routines in a directory with the command line:
      git diff (SHA1) (SHA2)

    GIT page Romain Pennel