Here are some things that I find useful in git. Basically this is my scratch pad of commands I need.
To set master to be equal to ‘tweaks’
git checkout tweaks git merge -s ours master git checkout master git merge tweaks
Stop your local file and accept theirs (or vice versa).
git checkout --ours filename.c git checkout --theirs filename.c
Undo the last commit (before you push)
git reset --soft HEAD^
git clean -d -x -n # removes all untracked and ignored files, change "-n" to "-f" to actually perform it
Now something XCode Clear out all the cruft.
Reverting a commit (actually reverting it, i.e. a new commit with the reverse merge)
git checkout core git branch core-experimental git reset --hard <SHA of last commit you want to keep> git push -f <remote> core
$ git ls-tree released-1.2.3 foo
Add all the files you don’t want to stash, then:
$ git stash --keep-index
Then unstage your changes if you didn’t really want to stage them with:
$ git reset --soft
git rm --cached filename
Getting diffing your changes before you push them:
git diff origin/master
git diff --cached
for remote in `git branch -r | grep -v master `; do git checkout --track $remote ; done