Skip to content

Instantly share code, notes, and snippets.

@Sleepful
Created August 21, 2026 21:15
Show Gist options
  • Select an option

  • Save Sleepful/728da7dc95d0153b3770cc25d22a8dc7 to your computer and use it in GitHub Desktop.

Select an option

Save Sleepful/728da7dc95d0153b3770cc25d22a8dc7 to your computer and use it in GitHub Desktop.
git aliases
[alias]
br = !git for-each-ref --sort=committerdate refs/heads --format='%(color:bold)%(align:15)%(HEAD)%(color:yellow)%(refname:short)%(end)%(align:20)%(color:bold green)%(committerdate:relative)%(end)%(color:magenta)%(authorname)\n%(color:blue)%(subject)\n%(color:reset)' --color=always|column -ts'|'
amend = commit --amend
p = push
pushb = push -u origin HEAD
pusht = push --tags
pushf = push --force-with-lease
a = add
au = add -u
aa = add -A .
c = commit
cm = commit -m
st = status
unstage = restore --staged
r = restore --staged
co = checkout
cob = checkout -b
genb = "!f(){ git checkout -b jv-`gdate -I`-$1; }; f"
logf = log --stat
logl = log -p
logo = log --oneline
fetcha = fetch --all
pulla = pull --all
pwd = branch --show-current
cls = "!cls(){ git check-ignore $(ls); }; cls"
clonesub = clone --recurse-submodules -j8
# checkout new branch with commit message:
# conew BRANCHNAME commit-msg
conew = "!conew(){ git checkout -b \"$1\" && git commit --allow-empty -m \"$2\" && git push -u origin HEAD; }; conew"
# delete branch from local and remote
# delbr BRANCHNAME
delbr = "!delbr(){ git branch -D \"$1\" && git push -d origin \"$1\"; }; delbr"
fixup = commit --fixup=HEAD
# HEAD is going to get squashed
# HEAD~ is the one that gets squashed into
# HEAD~~ is the base for the rebase, the non_inclusive limit to the rebase
refixup = rebase --autosquash -i HEAD~~
refu = -c sequence.editor=: rebase --autosquash -i HEAD~~
uncommit = reset --soft HEAD~
tracked = ls-tree --full-tree -r --name-only HEAD
rebaseprev = rebase --autosquash -i HEAD~~
# used to look at SHAs, e.g. g parse HEAD^
parse = rev-parse
# useful to edit with vimf
m = ls-files -m
# changed files from last commit
changes = !git --no-pager diff --name-only HEAD
prev = !git --no-pager diff --name-only HEAD^
prevprev = !git --no-pager diff --name-only HEAD^^ HEAD^
diffwithmain = !git --no-pager diff --name-only HEAD main
ignore-file = update-index --skip-worktree
unignore-file = update-index --no-skip-worktree
diffc = diff --cached
diffprev = diff HEAD^ HEAD
# rebase branch with merge commits into a single commit:
# git reset `g merge-base origin/main @`
# git commit
# git reflog show --no-abbrev <branch name>
logbranch = reflog show --no-abbrev
loghere = "!loghere(){ git reflog show --no-abbrev `git rev-parse --abbrev-ref HEAD`; }; loghere"
base = merge-base main HEAD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment