Here is my fancy Git setup to make things pretty and easy. First is the
[user] name = Steven Barre email = email@example.com [core] editor = vim [merge] tool = vimdiff [color] ui = auto [alias] br = branch ci = commit co = checkout dc = diff --cached di = diff last = log -1 HEAD lr = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=relative --graph ls = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short --graph la = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [Committed\\ by:\\ %cn]%Cgreen\\ [Authored\\ by:\\ %an]" --decorate --date=short --graph search = grep --break --heading --line-number -P st = status unstage = reset HEAD -- [push] default = current
This gives you a bunch of nice aliases, colorizes the output, and sets VIM as the default editor and merger.
The default push action lets you just say “git push” on a new branch and have it create a matching repo on the remote and set it as the upstream. git-config docs for reference.
Next we’ll add some goodies to
.bashrc to give us a pretty prompt.
First, we need to get the extra git shell functions loaded. We do this by linking the contrib file into
# sudo ln -s /usr/share/git-core/contrib/completion/git-prompt.sh /etc/profile.d/
Then put this into your
# Show colors for branch name and indicators export GIT_PS1_SHOWCOLORHINTS=1 # Show unstaged (*) and staged (+) export GIT_PS1_SHOWDIRTYSTATE=1 # Show if something is stashed ($) export GIT_PS1_SHOWSTASHSTATE=1 # Show if there are untracked files (%) export GIT_PS1_SHOWUNTRACKEDFILES=1 # User@Host:pwd $ # User@host:pwd (branch) $ export PROMPT_COMMAND='__git_ps1 "\[\033[31;1m\]\u\[\033[0m\]@\[\033[34;1m\]\h\[\033[0m\]:\[\033[33m\]\w\[\033[0m\]" " \$ "'
Here is what it looks like.
.bashrc ? Because it’s loaded for all bash shells, not just ones created when logging in. This is important if you are using
screen or a GUI terminal.
I’ve created a repo on GitHub to hold all my dotfiles to keep track of things like this.