Git shortcuts and tipps & tricks

Git history as ASCII graph

For example:

git history as ASCII graph

This can be achieved by defining an alias like git lg:

$ git config --global alias.lg "log --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr %an)%Creset' --abbrev-commit --date=relative"

Wiping all changes

To undo all changes that have been staged to the index and to remove all changes in the working tree, an alias like git wipe can be handy:

$ git config --global alias.wipe '!git reset --hard;git clean -fd'

Colored diff output

Use this to get colored output everywhere, even when editing commit messages:

git config --global color.ui auto
git config --global core.editor "nano -Y patch"

Quickly create a git repository in the current folder

Add this to your ~/.profile:

function git_here() {
    git init
    git config color.ui auto
    echo "log tmp db/*.sqlite3 nbproject/private bin .DS_Store" | tr " " "\n" > .gitignore
    git add .gitignore
    git commit -m "initial project setup"
}
Ralf Ebert

Ralf Ebert is an independent software developer and trainer. He makes apps for Mac OS X and iOS and offers iOS and Git training courses for software developers.