Skip to content

Instantly share code, notes, and snippets.

@rproenca
Created October 13, 2017 18:14
Show Gist options
  • Save rproenca/95c0dc7bebd68e16057571227f5f678c to your computer and use it in GitHub Desktop.
Save rproenca/95c0dc7bebd68e16057571227f5f678c to your computer and use it in GitHub Desktop.
Git alias - A list of useful git aliases

Based on: https://gist.github.com/mwhite/6887990

[alias]
    # one-line log
    l = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short

    a = add
    ap = add -p
    ac = !git add . && git commit -am
    c = commit --verbose
    ca = commit -a --verbose
    cm = commit -m
    cam = commit -a -m
    m = commit --amend --verbose

    d = diff
    dw = diff -w --color-words
    ds = diff --stat
    dc = diff --cached

    s = status -s
    co = checkout
    cob = checkout -b
    # list branches sorted by last modified
    b = "!git for-each-ref --sort='-authordate' --format='%(authordate)%09%(objectname:short)%09%(refname)' refs/heads | sed -e 's-refs/heads/--'"

    # list aliases
    la = "!git config -l | grep alias | cut -c 7-"

    undo-commit = reset --soft HEAD~1

    # shorcut for git push --set-upstream origin [branch-name]
    pushup = "!gitbranchname() { git symbolic-ref --short HEAD; }; gitpushupstream() { git push --set-upstream origin `gitbranchname`; }; gitpushupstream"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment