[Insight-developers] some useful git commands for ITK

Gaëtan Lehmann gaetan.lehmann at jouy.inra.fr
Mon Aug 2 11:05:00 EDT 2010


Here are some commands I've noted to use git with ITK.
They may be useful for others than me :-)
Some vocabulary may be partially inherited from darcs, but I guess it  
would be understandable anyway.

Gaëtan




# one time configuration on each host

git config --global user.name "Gaëtan Lehmann"
git config --global user.email "gaetan.lehmann at jouy.inra.fr"
git config --global color.ui auto
git config --global core.pager "less -FXRS"
# to use the same ssh key to commit to itk.org from different hosts
# the key can be generated with ssh-keygen -t rsa -N "" -f ~/.ssh/ 
id_git_itk
scp marvin:.ssh/id_git_itk ~/.ssh/id_git_itk
echo "Host itk.org" >> ~/.ssh/config
echo "  IdentityFile=~/.ssh/id_git_itk" >> ~/.ssh/config

# get ITK and its submodules

git clone git://itk.org/ITK.git
cd ITK
git submodule update --init

# configure the push url

git config remote.origin.pushurl git at itk.org:ITK.git

# get the hooks to run locally

cd .git/hooks
git init
git pull .. remotes/origin/hooks
cd ../..

# to update the repository

git pull --rebase

# to update the hooks

git fetch origin
cd .git/hooks
git pull .. remotes/origin/hooks

# view changes

git diff  # only non-indexed changes (without git add)
git diff --cached # only indexed changes (with git add) - what you're  
about to commit with git commit (without -a)
git diff HEAD # both indexed and non-indexed changes

# to revert all the changes - recorded patch are not lost

git reset --hard  # revert all the changes - indexed and non indexed

# to revert the changes in specific file(s)

git checkout -- a_file # do NOT revert the indexed changes (with git  
add)

# to commit some changes and push it in the main repository

git add a_file  # -p can be handy to select only a part of the changes
git commit -s  # -a can be handy to commit everything without the need  
to run git add
git push  # actually publish the committed patch on itk.org

# to rewrite the message of the last commit

git commit --amend

# uncommit the last patch

git reset HEAD^  # changes are not lost, just uncommited
git reset --hard REVISION~1 # changes are lost (!!!)
git revert  # generates a new patch to revert the previous one - to be  
used only if the previous patch has been published

# view patch history

git log --stat # on the full repository, with the list of modified files
git log a_file # on a single file
git show patch_id # the content of a patch

# view unpushed (unpublished) patches

git log origin..



-- 
Gaëtan Lehmann
Biologie du Développement et de la Reproduction
INRA de Jouy-en-Josas (France)
tel: +33 1 34 65 29 66    fax: 01 34 65 29 09
http://voxel.jouy.inra.fr  http://www.itk.org
http://www.mandriva.org  http://www.bepo.fr

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 203 bytes
Desc: Ceci est une signature ?lectronique PGP
URL: <http://www.itk.org/mailman/private/insight-developers/attachments/20100802/f057ceb5/attachment.pgp>


More information about the Insight-developers mailing list