Git Notes

One-liners

Add files to an old commit

Edit an old commit

Rebase master onto a branch

$ git checkout master
$ git pull origin master
$ git rebase master <branch>
# Make manual changes as needed
$ git rebase --continue

Pushing a rebased branch to a remote will require --force:

$ git push origin <branch> --force

Extract part of a repo to a new repo

IMPORTANT: Start with a fresh clone of the repository, not your working copy

$ git reset --hard
$ git gc --aggressive
$ git prune
$ git clean -fd

Convert Remote CVS Repository to Git

$ git cvsimport -v -d <CVS repo path> <module>
# where CVS repo path is similar to
#    :pserver:anonymous@a.cvs.sourceforge.net:/cvsroot/pcal

Applying patches with git

$ git apply --reject --whitespace=fix <patch>
$ wiggle --replace <file> <file.rej>

Diff