Git and GitHub CLI.
| Name | Runs | What it does | |
glog | git log --oneline --decorate --graph | one-line graph log | |
gloga | git log --oneline --decorate --graph --all | graph log, all branches | |
glast | git log -1 HEAD --stat | last commit with stats | |
gwho | git shortlog --summary --numbered | commits per author | |
function groot { git rev-parse --show-toplevel; }
groot | | print repository rootexample$ groot
/home/ali/projects/shop | |
function gundo { git reset --soft HEAD~1; }
gundo | | undo last commit, keep changes stagedexample$ gundo
(last commit undone, changes stay staged) | |
function gclean-preview { git clean -nd; }
gclean-preview | | show untracked files git clean would removeexample$ gclean-preview
Would remove build/
Would remove tmp.log | |
function gpristine {
git status --short
printf 'Discard tracked changes and remove untracked files. Type PRISTINE to continue: '
read -r _a
[ "$_a" = PRISTINE ] || { echo "Cancelled."; unset _a; return 1; }
unset _a
git reset --hard HEAD && git clean -fd # allow-destructive
}
gpristine | | discard all changes after typing PRISTINEexample$ gpristine
M api/user.go
?? tmp.log
Discard tracked changes and remove untracked files. Type PRISTINE to continue: no
Cancelled. | |
| Name | Runs | What it does | |
function gwip { git add -A && git commit --no-verify -qm "--wip-- [skip ci]" && git log -1 --oneline; }
gwip | | commit everything as a temporary WIP commitexample$ gwip
[main 3f1c9b2] --wip-- [skip ci] | |
function gunwip {
[ "$(git log -1 --format=%s)" = "--wip-- [skip ci]" ] || { echo "gunwip: last commit is not a WIP commit" >&2; return 1; }
echo "undid $(git log -1 --oneline)"; git reset -q HEAD~1
}
gunwip | | undo the last commit if it is a WIP commit, keep changesexample$ gunwip
undid 3f1c9b2 --wip-- [skip ci] | |
function gfixup {
[ "$#" -eq 1 ] || { echo "Usage: gfixup <commit>" >&2; return 2; }
git commit --fixup="$1" && GIT_SEQUENCE_EDITOR=: git rebase -i --autosquash "$1~1"
}
gfixup COMMIT | | commit staged changes as a fixup of COMMIT, then autosquashexample$ gfixup 3f1c9b2
[main 9a1b2c3] fixup! add login form
Successfully rebased and updated refs/heads/main. | |
function gclean-branches {
_b="$(git branch --merged | grep -v -E '^\*|^[[:space:]]*(main|master|develop)$' | sed 's/^[[:space:]]*//')"
[ -n "$_b" ] || { echo "No merged branches."; unset _b; return 0; }
echo "$_b"
yesno "Delete these merged branches?" && echo "$_b" | xargs git branch -d
unset _b
}
gclean-branches | | delete local branches already merged into the current one, after y/Nexample$ gclean-branches
feature/login
fix/typo
Delete these merged branches? [y/N] y | |
function gbl {
[ "$#" -ge 1 ] || { echo "Usage: gbl <file> [line]" >&2; return 2; }
if [ -n "${2:-}" ]; then git blame -w -L "$2,$2" -- "$1"; else git blame -w -- "$1"; fi
}
gbl FILE [LINE] | | who changed FILE (or one LINE of it), ignoring whitespaceexample$ gbl api/user.go 42
3f1c9b2 (Ali 2026-09-30 42) if err := validate(u); err != nil { | |