Last Updated: February 25, 2016
·
7.817K
· jan0sch

A good .gitconfig starting point.

This is a .gitconfig I've been using for some years now and it has proven quite okay. It should be saved in your home directory e.g. /home/johndoe/.gitconfig. The push directive is set to current maybe simple is also a good option for you.

[user]
    name = John Doe
    email = john.doe@example.com
[color]
    branch = auto
    diff = auto
    interactive = auto
    pager = true
    status = auto
    ui = true
[color "status"]
    added = green
    changed = yellow
    untracked = red
[push]
    default = current
[core]
    autocrlf = input
    pager = less -FRSX
[alias]
    ci = commit
    co = checkout
    st = status -sb
    lg = log --graph --pretty=format:'%C(yellow)%h%C(auto)%d%Creset %s %C(white)- %an, %ar%Creset'

Here is a link to the github gist.

8 Responses
Add your response

Here, another great example, https://github.com/gufranco/dotfiles/blob/master/.gitconfig.
With: --rebase options, alias, indentation and space corrections.
Comments are in portuguese.

over 1 year ago ·

@fernandoperigolo Thanks for the link. There are some nice aliases there. :-)

over 1 year ago ·

For shortening your Git commands I would rather use shell aliases: https://coderwall.com/p/i3leza

over 1 year ago ·

@jaccus With shell aliases you never know with which commands they may collide if you use (or are forced to use) a lot of different platforms and shells. Therefore I reduced my shell aliases to a bare minimum.

But if you're always on the same kind of plattform/environment I would also go for shell aliases because they're much shorter. :-)

over 1 year ago ·

@jan0sch
I prefer %C(auto)%d%Creset because the different types of branches (HEAD, local, remote) are displayed in different colors (better readability!)

over 1 year ago ·

@pmiossec Great hint! I've updated my gist accordingly. Really great if you happen to have a lot of branches.

over 1 year ago ·

I'll throw mine into the ring.

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

I much prefer "git status -sb" for the "git st" alias. Smaller status output FTW! :)

over 1 year ago ·

@magnetikonline There was a reason why I didn't use it as default. Although I can't remember it anymore. ;-) I believe it was due to a bug several git versions back.

over 1 year ago ·