211 views
0
Useful GIT alias commands
l = log --graph --abbrev-commit --decorate --pretty=format:'%C(auto)%h %d %s %C(black)%C(bold)%cr' --all
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
bigstatus = status -b -v -v
co = checkout
cob = checkout -b
qpush = !"msg=${1:-wip}; git add -A && git commit -m \"$msg\" || true; git push"
# 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-"
pullhere = "!f(){ for d in */.git; do (cd \"${d%/.git}\" && echo \"Updating ${d%/.git}\" && git pull); done; }; f"
pullmain = "!f(){ for d in */.git; do (cd \"${d%/.git}\" && echo \"Updating ${d%/.git}\" && if git show-ref --verify --quiet refs/heads/main || git show-ref --verify --quiet refs/remotes/origin/main; then git checkout main; else git checkout master; fi && git pull); done; }; f"
pulltest = "!f(){ for d in */.git; do (cd \"${d%/.git}\" && echo \"Updating ${d%/.git}\" && if git show-ref --verify --quiet refs/heads/test || git show-ref --verify --quiet refs/remotes/origin/test; then git checkout test; else git checkout test2; fi && git pull); done; }; f"
pulldevelop= "!f(){ for d in */.git; do (cd \"${d%/.git}\" && echo \"Updating ${d%/.git}\" && if git show-ref --verify --quiet refs/heads/develop || git show-ref --verify --quiet refs/remotes/origin/develop; then git checkout develop; else git checkout develop2; fi && git pull); done; }; f"
pullall = "!git pullmain; git pulltest; git pulldevelop"
nuke = !git branch | grep -v \"develop\" | grep -v \"master\" | grep -v \"main\" | grep -v \"test\" | xargs git branch -D
nukeall = "!f(){ for d in */.git; do (cd \"${d%/.git}\" && echo \"Nuking ${d%/.git}\" && git branch --format='%(refname:short)' | grep -Ev '^(master|main|test|develop)$' | while IFS= read -r branch; do git branch -D \"$branch\"; done); done; }; f"
nukeworktrees = "!f(){ for d in \"$HOME\"/source/worktrees/*; do [ -d \"$d\" ] || continue; repo=$(git -C \"$d\" rev-parse --path-format=absolute --git-common-dir 2>/dev/null) || continue; branch=$(git -C \"$d\" symbolic-ref --quiet --short HEAD 2>/dev/null); echo \"Removing $d\"; git --git-dir=\"$repo\" worktree remove --force \"$d\"; git --git-dir=\"$repo\" worktree prune; if [ -n \"$branch\" ] && ! git --git-dir=\"$repo\" worktree list --porcelain | grep -Fxq \"branch refs/heads/$branch\"; then git --git-dir=\"$repo\" branch -D \"$branch\"; fi; done; }; f"
diffnew = diff HEAD~1 HEAD
codalatatest · 2026-10-27 09:09:36
codalatatest · 2026-10-27 09:12:29