login

Git: Commands & Aliases

Useful commands and aliases for a better Git experience.

2023-11-15


My git aliases explained:

My git alias config section:

[alias]
    st = status -sbu
    cm = commit -m
    co = checkout
    ap = !git add -N . && git add -p
    cob = checkout -b
    brd = branch -D
    br = branch --format='%%(color:yellow)%%(HEAD)%%(color:reset) %%(color:blue)%%(refname:short)%%(color:reset)  %%(contents:subject) - %%(color:green)%%(authorname)%%(color:reset)' --sort=-committerdate
    ll = log --abbrev-commit --format='%%C(blue)%%h%%C(reset) %%C(yellow)%%d%%C(reset) %%s - %%C(green)(%%cr) [%%an]%%C(reset)'
    lg = log --graph --abbrev-commit --format='%%C(blue)%%h%%C(reset) %%C(yellow)%%d%%C(reset) %%s - %%C(green)(%%cr) [%%an]%%C(reset)'
    lf = log --follow --abbrev-commit --format='%%C(blue)%%h%%C(reset) %%C(yellow)%%d%%C(reset) %%s - %%C(green)(%%cr) [%%an]%%C(reset)'
    df = diff
    c = commit
    p = pull
    f = fetch
    save = !git add -A && git commit -m 'chore: commit save point'
    undo = reset HEAD~1 --mixed
    wipe = !git restore .
    erase = !git reset --hard
    done = !git push origin HEAD

My git workflow for feature implementation:

git p
git cob feat/example
...
git ap
git c
git done