Skip to content

Instantly share code, notes, and snippets.

@ihower
Created July 12, 2020 08:00
Show Gist options
  • Select an option

  • Save ihower/66e3139f306e420c60e334e1e45fc9f4 to your computer and use it in GitHub Desktop.

Select an option

Save ihower/66e3139f306e420c60e334e1e45fc9f4 to your computer and use it in GitHub Desktop.

Revisions

  1. ihower created this gist Jul 12, 2020.
    71 changes: 71 additions & 0 deletions .gitconfig
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,71 @@
    [user]
    name = Wen-Tien Chang
    email = [email protected]

    [alias]
    co = checkout
    ci = commit
    st = status
    br = branch -v
    rt = reset --hard
    unstage = reset HEAD
    uncommit = reset --soft HEAD^
    ls = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate
    l = log --pretty=oneline --abbrev-commit --graph --decorate
    amend = commit --amend

    who = shortlog -n -s --no-merges
    who1 = shortlog -sn --no-merges --since='1 month'
    who2 = shortlog -sn --no-merges --since='2 months'
    who3 = shortlog -sn --no-merges --since='3 months'
    who4 = shortlog -sn --no-merges --since='4 months'
    who5 = shortlog -sn --no-merges --since='5 months'
    who6 = shortlog -sn --no-merges --since='6 months'
    who12 = shortlog -sn --no-merges --since='12 months'

    # https://preslav.me/2020/03/01/use-the-git-history/
    code-changes = "!git log --format=format: --name-only | egrep -v '^$' | sort | uniq -c | sort -rg | head -10"
    cc = "!git code-changes"

    # https://csswizardry.com/2017/05/little-things-i-like-to-do-with-git/
    recent = for-each-ref --count=10 --sort=-committerdate refs/heads/ --format="%(refname:short)"
    overview = log --all --since='2 weeks' --oneline --no-merges --since='2 weeks'

    date = for-each-ref --sort=-committerdate --format='%(committerdate:short) %(authorname) %(refname:short)'

    g = grep -n --color -E
    ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat
    ld = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=relative

    cp = cherry-pick -x
    nb = checkout -b
    pullff = pull --ff-only

    # Handy shortcuts for rebasing
    rc = rebase --continue
    rs = rebase --skip
    ra = rebase --abort

    # https://coderwall.com/p/ndinba
    latest = for-each-ref --sort=-committerdate --format='%(committerdate:short) %(refname:short)'
    local-latest = for-each-ref --sort=-committerdate refs/heads --format='%(committerdate:short) %(refname:short)'

    [color]
    diff = auto
    status = auto
    branch = auto
    ui = true

    [apply]
    whitespace = warn
    [rerere]
    enabled = false
    # https://blog.scottnonnenberg.com/better-git-configuration/
    [push]
    followTags = true
    [status]
    showUntrackedFiles = all
    [rebase]
    autoStash = true
    [pull]
    rebase = false