Here are some useful git config options for
- Displaying colors in status and diff outputs.
- Creating aliases and shortcuts for common git commands.
- Setting shortcuts from the command line itself.
First, create a ~/.gitconfig
file for your user account, which will store the changes we are about to make.
touch ~/.gitconfig
To add color to git output, add the following to the file
[color]
diff = auto
status = auto
branch = auto
interactive = auto
ui = true
pager = true
I don't like typing git status
every time that I have to check on my repo. git st
should do it. Here is how to do that (and some more). Add the following to your ~/.gitconfig
.
[alias]
co = checkout
ci = commit
st = status
br = branch
hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
type = cat-file -t
dump = cat-file -p
Also, you can come up with even shorter shortcuts. You could add new aliases to your ~/.bashrc
like alias gdiff='git diff'
or alias gst='git status'
.
And if you are in a hurry, you can always setup your shortcuts from the command line.
git config --global user.name username
git config --global user.email [email protected]
git config --global alias.co checkout
git config --global alias.st "status"
git config --global alias.stat "status"
git config --global alias.br branch
git config --global alias.wdiff "diff --color-words"
git config --global merge.tool diffuse
git config --global merge.summary true
git config --global difftool.prompt false
git config --global diff.tool diffuse
git config --global merge.tool diffuse
git config --global color.ui true