8 comments

[ 2.9 ms ] story [ 38.2 ms ] thread
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. :/

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)

(comment deleted)
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.

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]
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!