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 stgit status #

The full status output. It’s my default “what changed?” command.

git cogit 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 main to switch branches.
  • git co -b feat/new-post to create and switch.
  • git co <commit-sha> when I need to inspect old state.

git brgit branch --sort=-committerdate #

Shows recently active branches first instead of alphabetical order.

Ways I use it:

  • git br to scan active branches.
  • git br -a to include remote branches.

git lggit log --oneline #

Quick commit history, minimal noise.

Ways I use it:

  • git lg for recent commits (but ).
  • git lg -n 100 for a deeper look.
  • git lg --author="<author>" to filter by author.

git pogit 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 pomgit 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 caangit 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 caan during local cleanup before pushing.
  • git caan right 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 refreshgit 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 rpomgit 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 amnesiagit 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 recallgit update-index --no-assume-unchanged #

Reverses amnesia so Git tracks changes to that file again.

git forgetfulnessgit ls-files -v | grep ^[a-z] #

Lists files currently marked with assume-unchanged (the ones Git is “forgetting”).