Git Cheat-Sheet
The following are some receipts for doing unusual things with git. Not unusual for power users of course, but sufficiently unusual that the weirdness is not captured by my long term memory (which is good - I don't want git to appear more important to my brain than things that actually matters).
Merge
Merge a branch into the current branch without history. I some times use this for merging feature branches or refactor branches where the history is of little significance.
1git merge --squash <branch>
Merge a branch with history, but associate the commits with it's original branch. (It gives a better visual understanding of the projects history if you examine the history in a graphical tool, like gitk).
git merge --no-ff <branch>
Push
Push branch to a remote server (in this case origin). I often do this to have feature branches I work on safely backed up in case my PC gets lost, or to allow others to take a look at my code before I merge a feature in to the master branch.
1git push -u origin <branch>
Pull
Pull from an unrelated repository. Typically, when I have a local git-repository with code in it, and want to push to a newly created public repository, for example on GitHub. I pull from the public repository, handles merge conflicts, and then push.
1git pull --allow-unrelated-histories origin master
Submodules
Update (and optionally init) submodules
1git submodule update --remote --merge --recursive --init
Undo
Undo the most recent commit (for example to ad more changes or change the comment).
1git reset --soft HEAD~