Useful git commands

Useful git tricks I’ve learned that I always end up coming back to:

Replace master with another branch:

From stackoverflow:

git checkout seotweaks
git merge -s ours master
git checkout master
git merge seotweaks

Update the submodules in a newly cloned project:

From the git book:

git submodule init
git submodule update


Clone a repository:

git svn clone local_dir

Useful flags:

-s standard layout (trunk branches tags)
-r 1000:HEAD specific revisions

Create ignore files:

echo ".gitignore" >> .git/info/exclude
git svn create-ignore

Commit back to SVN:

git svn dcommit
Robin Deits 02 May 2012