Last Updated: December 26, 2018
· juliomistral

The Bestest Git Setup

When I'm helping out one of the other guys with a git problem, I always get a major sad because they don't have git setup all nice and pretty like I do.

So here's the setup I like (from my ~/.gitconfig</code>):

    diff = auto
    status = auto
    branch = auto
    interactive = auto
    ui = true
    pager = true
[color "status"]
    added = green
    changed = yellow
    untracked = red
    excludesfile = $HOME/.gitignore
    pager = less -FRSX
    whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
    ci = commit
    co = checkout
    st = status
    lg = log --graph --pretty=format:'%C(yellow)%h%C(cyan)%d%Creset %s %C(white)- %an, %ar%Creset'
    dtc = difftool --cached

[difftool "Kaleidoscope"]
    cmd = ksdiff-wrapper git \"$LOCAL\" \"$REMOTE\"
    prompt = false
    tool = Kaleidoscope

And I add this little nugget to my ~/.bash_profile</code> so that I can get Git autocomplete and a status on my prompt (current HEAD and whether my working branch is dirty):

# Set git autocompletion and PS1 integration
if [ -f /usr/local/git/contrib/completion/git-completion.bash ]; then
  . /usr/local/git/contrib/completion/git-completion.bash

PS1='\[\033[32m\]\u:\[\033[34m\]\w\[\033[31m\]$(__git_ps1)\[\033[00m\]\$ '

3 Responses
Add your response


Good tip, I just installed this:

It does a bunch of other cool things as well as a better git setup in terminal.

over 1 year ago ·

Probably the most valuable difftool switch I have found recently is "-d", which is available in more recent Git builds. Great for diffing many files in a visual diff tool that can handle directories.

As used here with the "da" alias.


over 1 year ago ·

If you have your dotfiles in a git repo may find it useful to use "excludesfile = ~/.gitexcludes" instead, that way your dotfile-specific ignores don't run the risk of getting applied globally.

over 1 year ago ·