############################################## ############################################## # GIT Cheat's ############################################## Initial ######## URLs git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6.git git://git.kernel.org/pub/scm/linux/kernel/git/acme/pahole.git http://sources.redhat.com/git/systemtap.git rsync://rsync.kernel.org/pub/scm/linux/kernel/git/tglx/hrtimer-2.6.git rsync://rsync.kernel.org/pub/scm/linux/kernel/git/shemminger/iproute2.git rsync://rsync.kernel.org/pub/scm/linux/kernel/git/axboe/blktrace.git ######## Clone vanilla clone # git-clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git linux-2.6 Clone via reference # git-clone --reference ./linux-2.6 git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6.git net-2.6 ######## New Project (aka initial import) New Project # mkdir hack_session; cd hack_session # git init-db # git add . # git commit ############################################## Change Repository ######## Checkout Revert a file local # git checkout -- Revert all local files # git checkout -f ######## Commit Commit everything what changed since last commit with a SoB message (display with "git diff HEAD") # git commit -a -s ######## Pull Fast Forward Merge # git pull ######## Branches Create a branch # git branch -f or # git branch workingbranch master # git checkout workingbranch Show all branches # git branch ############################################## See what happend -- Gather Information ######## Diff See what you commit if you commit # git diff HEAD ######## Log Display what changed since a defined amount of time # git log --since='2 days ago' Display log between current branch (HEAD) and master # git log master..HEAD As usual, the best way to get some grip on a particular subsystem would tend to be with some script like. List by commiters # git log --no-merges v2.6.18.. drivers/usb | git shortlog | less -S ######## Blame Display who wrote a specific lime of code # git blame ######## Show Display what changed through the specific commit # git show ######## Patch Generate a patch for diff between master and HEAD # git format-patch master..HEAD Generate a patch for the last local commit with SoB message and ignore introduced whitespace errors and generate a nice looking subject line ([PATCH n/m] ...) the C option detect copies # git format-patch -s -b -n -C -1 Generate a delta between you branch and the master branch (HEAD is an alias for your working branch) # git format-patch master workingbranch ############################################## Subversion and GIT Initialize a repo (like git init): #git-svn clone svn+ssh://hgndgtl@svn.berlios.de/svnroot/repos/netsend netsend #git svn init https://libhashish.svn.sourceforge.net/svnroot/libhashish Do some work, and then commit your new changes to SVN, as well as automatically updating your working HEAD: # git-svn dcommit Something has been committed to trunk, rebase the latest into your branch: #git-svn rebase ############################################## Find A Bug (good luck) Bisect the source # git bisect start # git bisect bad # git bisect good v2.6.13-rc2 # git bad or # git good # git bisect reset ############################################## Additional Information ######## Send patch via mutt Generate a patch (git format-patch) and invoke mutt via -H # mutt -H 00*.patch ######## Send multiple patches Send multiple patches via git-send-email and compose an introduction email, but first generate all patches: # git format-patch -C -n -1 # git send-email --compose --suppress-from --to 00*.patch ######## Apply patched received via mutt Save the patch (as a normal attachment), go to the git repo and type git am ######## Global Configuration # ~/.gitconfig [user] name = "Hagen Paul Pfeifer" email = "hagen@jauu.net" [sendemail] bcc = hagen@jauu.net chainreplyto = false smtpserver = /home/pfeifer/bin/sendmail.sh [color] status = auto diff = auto branch = auto [color "branch"] current = yellow reverse local = yellow remote = green [color "diff"] meta = yellow bold frag = magenta bold old = red bold new = green bold [color "status"] added = yellow changed = green untracked = cyan [alias] st = status ci = commit co = checkout [core] legacyheaders = false excludesfile = /home/pfeifer/.gitignore [repack] usedeltabaseoffset = true ######## The upper sendmail script: #!/bin/sh exec /usr/bin/ssh -T pfeifer@0xdef.net /usr/sbin/sendmail "$@"