DEV Community

Sebastian Camilo Marquez
Sebastian Camilo Marquez

Posted on

Git aliases for better efficiency and convenience

[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
    c = commit --verbose
    ca = commit -a --verbose
    cm = commit -m
    cam = commit -a -m
    m = commit --amend --verbose

    d = diff
    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-"
Enter fullscreen mode Exit fullscreen mode

Top comments (2)

Collapse
 
dionarodrigues profile image
Diona Rodrigues

Good cheatsheet. Git aliasses is always good to know.

Collapse
 
chrisnowicki profile image
Chris Nowicki

Very cool cheat sheet! Would love to hear more about other git efficiency shortcuts you may have :).