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.
|Base command||Useless functionality||Useful command||Useful functionality|
|git branch foo||Creates a branch but does nothing with it||git checkout -b foo||Creates branch and switches to it|
|git remote||Shows names of remotes||git remote -v||Shows names and URLs of remotes|
|git stash||Stores modifications to tracked files, then rolls them back||git stash -u||Also does the same to untracked files|
|git branch||Lists names of local branches||git branch -rv||Lists local and remote tracking branches; shows latest commit message|
|git rebase||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||Unstages files||git reset –hard|
git reset –soft
|Discards local modifications|
Returns to another commit, but doesn’t touch working directory.
|git add||Nothing – prints warning||git add .|
git add -A
|Stages all local modifications/additions|
Stages all local modifications/additions/deletions