Skip to content

Instantly share code, notes, and snippets.

@dougwaldron
Last active October 23, 2025 21:04
Show Gist options
  • Select an option

  • Save dougwaldron/b120b8a44766a5c9f0461a747359b905 to your computer and use it in GitHub Desktop.

Select an option

Save dougwaldron/b120b8a44766a5c9f0461a747359b905 to your computer and use it in GitHub Desktop.
Git aliases
# Alias source: https://gist.github.com/dougwaldron/b120b8a44766a5c9f0461a747359b905
# Use `git config --edit --global` to open and edit the .gitconfig file
[alias]
# Edit global config (this document)
cg = config --edit --global
# Edit local config
cl = config --edit
# Stage all and show status
a = !git add . && git status -s -u
# cleaner status
s = status -s -u
# prettier logs
l = log --pretty=format:'%C(bold cyan)%cr%C(reset)%C(auto) %s%d' --graph --date=short -10
# same with hashes & users
lu = log --pretty=format:'%C(bold cyan)%cr%C(reset)%C(auto) %C(bold yellow)<%aN>%C(reset)%C(auto) %s%d' --graph --date=short -10
# more info than you require
lm = log --pretty=format:'%C(bold green)%h %C(bold cyan)(parents: %p)%C(reset)%C(auto) %s%d' --graph --date=short --decorate=full -10
# show all refs
la = log --pretty=format:'%C(bold cyan)%cr%C(reset)%C(auto) %s%d' --graph --date=short --all -10
lh = log --pretty=format:'%C(green)%h%C(reset)%C(auto) %s%d' --graph -5
# show hashes for all refs
lah = log --pretty=format:'%C(green)%h %C(bold cyan)%cr%C(reset)%C(auto) %s%d' --graph --date=short --all -10
# last commit
last = log -1 HEAD
# Catch up
sup = !git fetch --all && git l && git s
# list all contributors (who)
w = shortlog -sne
who = shortlog -sne
# recent commit details
# (optionally use `-n` to limit number of commits shown)
d = log --stat --summary
# files changed by recent commits
# (optionally use `-n` to limit number of commits shown)
f = log --name-status --oneline
# verbose output about branches or remotes
b = branch -a -vv
r = remote -v
# push all branches (verbosely)
# (optionally add name of remote)
pa = push --all --verbose
# Push all tags (verbosely)
# (optionally add name of remote)
pt = push --tags --verbose
# Update main branch to origin
pullmain = !git fetch --all && git checkout main && git pull --ff-only
# Nice diff format
df = diff --word-diff-regex=.
sh = show --word-diff-regex=.
# Rebase child branch after parent branch has been merged
# (This would cause problems if the parent branch was squash-merged.)
# Usage:
# > git checkout child-branch
# > git crb parent-branch
# See: https://stackoverflow.com/a/56810435/212978
crb = rebase --onto main
# List all the aliases!
aliases = config --get-regexp '^alias\\.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment