-89vba
Last Updated: December 26, 2018
·
4.168K
· 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>):

[color]
    diff = auto
    status = auto
    branch = auto
    interactive = auto
    ui = true
    pager = true
[color "status"]
    added = green
    changed = yellow
    untracked = red
[core]
    excludesfile = $HOME/.gitignore
    pager = less -FRSX
    whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
[alias]
    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\"
[difftool]
    prompt = false
[diff]
    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
fi

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

3 Responses
Add your response

3776

Good tip, I just installed this:
https://github.com/mathiasbynens/dotfiles

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

over 1 year ago ·
3845

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.

https://github.com/magnetikonline/dotfiles/blob/master/.gitconfig

over 1 year ago ·
5331

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 ·