Aliases in my .gitconfig
Aliases I've accumulated in my .gitconfig over the years, mostly as a byproduct of repetition.
Aliases #
[alias]
st = status
co = checkout
br = branch --sort=-committerdate
lg = log --oneline
po = pull origin
pom = pull origin main
caan = ! git add . && git commit -a --amend --no-edit
rpom = ! git co main && git refresh && git pull origin main
refresh = ! git fetch --all && git remote prune origin
amnesia=update-index --assume-unchanged
recall=update-index --no-assume-unchanged
forgetfulness=! git ls-files -v | grep ^[a-z]
Full list of aliases, with breakdowns below.
Speed / Brevity #
[alias]
st = status
co = checkout
br = branch --sort=-committerdate
lg = log --oneline
po = pull origin
pom = pull origin main
git st → git status #
The full status output. It’s my default “what changed?” command.
git co → git checkout #
I'm aware that git switch and git restore are preferred, but I have yet to consistently adopt these due to my muscle memory for this shortcut.
Ways I use it:
git co mainto switch branches.git co -b feat/new-postto create and switch.git co <commit-sha>when I need to inspect old state.
git br → git branch --sort=-committerdate #
Shows recently active branches first instead of alphabetical order.
Ways I use it:
git brto scan active branches.git br -ato include remote branches.
git lg → git log --oneline #
Quick commit history, minimal noise.
Ways I use it:
git lgfor recent commits (but ).git lg -n 100for a deeper look.git lg --author="<author>"to filter by author.
git po → git pull origin #
Shortcut for pulling from origin without retyping the remote name.
Ways I use it:
git po <branch>to pull a specific remote branch.
git pom → git pull origin main #
One command to sync the current branch with origin/main.
Composites #
[alias]
caan = ! git add . && git commit -a --amend --no-edit
rpom = ! git co main && git refresh && git pull origin main
refresh = ! git fetch --all && git remote prune origin
git caan → git add . && git commit -a --amend --no-edit #
Amends the latest commit with current changes, keeping the same message. In practice, this feels like right-click + save.
Ways I use it:
git caanduring local cleanup before pushing.git caanright after addressing a suggestion in a Github PR review.
Note: Amending rewrites commit history. Force pushes will be needed if the commit is already shared, so be cognizant of the potential risks.
git refresh → git fetch --all && git remote prune origin #
I do this frequently to ensure that my local branches are up to date with remote, and that I'm not harboring any stale remote branches.
git rpom → git co main && git refresh && git pull origin main #
I pronounce this "arr palm". My “reset context” command: switch to main, refresh remotes, then pull latest main. I use this primarily before starting a new branch off of main, or when completing Task A and starting Task B.
Amnesia Toolkit #
[alias]
amnesia=update-index --assume-unchanged
recall=update-index --no-assume-unchanged
forgetfulness=! git ls-files -v | grep ^[a-z]
These commands were handed down to me from a former manager.
git amnesia → git update-index --assume-unchanged #
Tells Git to temporarily ignore local edits to a tracked file.
If you're not yet sure of whether to stash or commit, use git amnesia <filepath> for local-only tweaks.
git recall → git update-index --no-assume-unchanged #
Reverses amnesia so Git tracks changes to that file again.
git forgetfulness → git ls-files -v | grep ^[a-z] #
Lists files currently marked with assume-unchanged (the ones Git is “forgetting”).