Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
What does your .gitconfig contain? (stackoverflow.com)
78 points by j2d2j2d2 on April 25, 2011 | hide | past | favorite | 7 comments


Aside from the standard stuff I have:

  # Usage: git whatsnew <other_branch>
  # Show commits that are in the current branch,
  # but not in <other_branch>. Great for an
  # instant changelog.
  whatsnew = !sh -c 'git shortlog --format=\"%h %s\" $1..HEAD' -

  # Usage: git omgwtfbbq
  # abort/reset/clean/etc everything back to HEAD.
  # DESTRUCTIVE!  Handy if you get git into a
  # really odd state, during a merge, though...
  omgwtfbbq = !sh -c '~/.bin/git-omgwtfbbq'
 
  # and in ~/.bin/git-omgwtfbbq
    #!/bin/bash

    # Get confirmation from user
    read -p "This will erase any work done and reset to HEAD. Continue? [yN] " -n1
    if [[ ! $REPLY =~ ^[Yy]$ ]]
    then
      exit 1
    fi

    echo ''
    # Reset everything
    git clean -f && (git rebase --abort || git reset --hard)
[edit: formatting]


A thing I learned about while researching the examples in that thread: if you set the color.ui setting to "auto", then that is used as the default for all the other color-enabling options - it turns out they'd added a few more since I last updated my config file.

Also, my favourite aliases are "cherrypick" for "cherry-pick" and "merge-tool" for "mergetool"; why they couldn't standardize their hyphenation convention, I don't know. :/


Since I mostly use git I have 'st' aliased in my .bashrc

Also git dt = git difftool

Default difftool set to http://www.kaleidoscopeapp.com/

EDIT: Forgot about the following: core.editor = mate -w alias.unstage = reset HEAD --

mate -w opens text mate (http://macromates.com/) in blocking mode.


I find it easier to add shell aliases, so e.g. instead of typing 'git add', just type 'add'.

This conflicts with normal 'diff', so I add 'di', plus I have 'changed'='git diff' and 'staged'='git diff --cached', so I don't need 'git diff' so often anyway.

Then I use .gitconfig for all the commands I wish git had, e.g. 'unstage = reset HEAD', 'amend = commit --amend', etc.


My favorite aliases:

st = status -sb (more compact status. Can always use the full word "status" if I want the normal one, but I don't think I've done that once since I set the alias. Not original, I found it online somewhere)

dfc = diff --cached

dfw = diff --word-diff

msg = commit --allow-empty -m (http://ozmm.org/posts/git_msg.html)


Mostly some quick aliases in mine: https://github.com/strmpnk/dotfiles/blob/master/.gitconfig

I do like the push mode setting in newer git versions as well.


The nicest things for me are the addition of tab completion, and including my current branch in my command line prompt. I'd be lost without that one now!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: