Git Cheatsheet For Some Not So Common Activities

Post Receive Hook to Update The Checked Out Copy

#!/bin/sh
cd ..
env -i git reset --hard

Add a remote

Note: There is no : between the host and the path

git remote add origin ssh://user@host/path/to/repo/.git

Undo the last commit

If you want the changes to stay in the working directory but just want to undo the actual commit.

git reset --soft HEAD^

If you want to get rid of the last change completely then to.

git reset --hard HEAD^

Display a pretty history of the git repository

git log --graph --all --pretty=format:'%Cred%h%Creset - %an %Cgreen%cr%Creset %s%C(yellow)%d%Creset' --abbrev-commit --date=relative