Useful git configuration settings¶
These options can be configured in your global git config file e.g. ~/.gitconfig on Linux:
[user]
name = Your Name
email = your@email.net
[color]
ui = true
[core]
editor = vim
[fetch]
prune = true
pruneTags = true
all = true
[merge]
tool = meld
[mergetool]
keepBackup = false
[pull]
rebase = false
[push]
default = simple
autoSetupRemote = true
followTags = true
[status]
showUntrackedFiles = all
[tag]
sort = version:refname
Or using shell commands e.g.
git config --global fetch.prune true
Prompt with branch and dirty indicator¶
vim ~/.bashrc
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}
PS1='\[\e[1;34m\]\u@\h:\w\[\e[0;32m\]$(parse_git_branch)\[\e[1;34m\]\$ \[\e[m\]'