Git Configuration Options

By Jimmy Bonney | November 17, 2012

Git

For the same reason that pushed me to publish my configuration of Sublime Text 2, I will introduce my git configuration file in this article. This will allow me to import it more easily on other systems when I need it (and it might inspire someone else to use (some part of) it as well).

The current configuration (it lies in the ~/.gitconfig file in a Linux environment) can be found below and an up-to-date configuration file is available on this gist:

[user]
    name = Your Name
    email = ...@email.com
[alias]
    ls = ls-files
    co = checkout
    ci = commit
    br = branch
    df = diff
    dc = diff --cached
    dm = diff | mate
    lg = log -p
    gl = git pull
    gp = git push
    st = status
    lol = log --graph --decorate --pretty=oneline --abbrev-commit
    lola = log --graph --decorate --pretty=oneline --abbrev-commit --all
    # Show files ignored by git:
    ign = ls-files -o -i --exclude-standard
    tree = log --graph --simplify-by-decoration --pretty=format:'%d' --all
    sync = remote prune origin
[apply]
    whitespace = nowarn
[color]
    ui = auto
[color "branch"]
    current = green
    local = normal
    remote = red
    plain = normal
[color "diff"]
    plain = normal
    meta = bold
    frag = cyan bold
    old = red bold
    new = green bold
    commit = yellow
[color "status"]
    header = normal
    added = blue
    updated = green
    changed = yellow
    untracked = cyan
    nobranch = red
[branch]
    autosetupmerge = true
[diff]
    external = git-diff-meld

Most of the options defined above are taken directly from a cheat sheet but I have updated the colors to something that makes more sense to me.

In addition, I have added a couple of aliases found somewhere else on the web:

  • tree = log --graph --simplify-by-decoration --pretty=format:'%d' --all allows to simply display the tree of local and remote branches. It does not include the details of the commits for each branch. It makes it easier to identify where branches take their roots, where they are merged, etc… This is directly taken from Stackoverflow.
  • sync = remote prune origin simply cleans the local cache of “dead” remote branches in order to remove branches that would have been deleted remotely. This is the usual prune command found in Git documentation.

Git tree illustration

The autosetupmerge option is clarified in the cheat sheet as well and allow to track a remote branch by default so that one can omit the --track when creating new local branches from remote ones.

Finally, the [diff] section sets up an external tool to be used when running the git diff command. In this specific case, meld will be started with some appropriate arguments.


Credits Image

git


For the time being, comments are managed by Disqus, a third-party library. I will eventually replace it with another solution, but the timeline is unclear. Considering the amount of data being loaded, if you would like to view comments or post a comment, click on the button below. For more information about why you see this button, take a look at the following article.