Here’s my current .gitconfig file. It’s very simple, but it makes using git so much better. git s is a simplified git status, and git l is a log that shows one-line commit messages and a tree that shows where branches and merges were made.
[color] ui = true [alias] s = status -su l = log --graph --pretty=format:'%C(yellow)%h%C(cyan)%d%Creset %s %C(white)- %an, %ar%Creset'
I also highly recommend you check out the table below, which I’ve copied from the bottom of the 10 things I hate about git post. It helps make sense of some common commands that I thought were useless as well. Adding the switches Steve Bennett recommends clears things up a bit.
|git branch foo
|Creates a branch but does nothing with it
|git checkout -b foo
|Creates branch and switches to it
|Shows names of remotes
|git remote -v
|Shows names and URLs of remotes
|Stores modifications to tracked files, then rolls them back
|git stash -u
|Also does the same to untracked files
|Lists names of local branches
|git branch -rv
|Lists local and remote tracking branches; shows latest commit message
|Destroy history blindfolded
|git rebase -i
|Lets you rewrite the upstream history of a branch, choosing which commits to keep, squash, or ditch.
|git reset foo
|git reset –hard
git reset –soft
|Discards local modifications
Returns to another commit, but doesn’t touch working directory.
|Nothing – prints warning
|git add .
git add -A
|Stages all local modifications/additions
Stages all local modifications/additions/deletions