Better git command names
I presented this content in a light-hearted lightning talk at Prezi’s Draft Conference in 2022:
Getting comfortable with git is famously challenging, and I do believe part of this is that git commands are named very poorly. The documentation often only manages to increase confusion — see the git-man-page-generator for a hilarious demonstration of what most of us feel like while trying to make sense of git docs.
restore? Is it
--staged? If adding something to the staging area is called
is removing it from the staging area not called
remove? What the hell is
rev-parse --abbrev-ref supposed to mean? After
years on years of working with git on a daily basis, the frustration never really went away. So, in true Naming Things
is Hard fashion, here are my git aliases that make it ever so slightly easier to make sense of the workflow.
You can import them from the related git repository.
status --short(mostly because st is taken by stage)
checkout(used for commits)
add :/(stage all files in the repo starting from the root)
add -a(interactively select files to stage)
diff --staged(I never understood why people use ‘cached’, not ‘staged’ for this command)
commit(included here for completeness)
stage-all && commit(let’s avoid having to introduce the concept of ‘tracked’ and ‘untracked’ files - if I ask git to commit all, I really meant all).
reset @^(do the opposite of what commit did)
reset --hard @^(get rid of it altogether)
restore :/(as if you had pressed undo in your editor)
rebase -i(interactive rebasing hasn’t much to do with rebasing, and ‘rebasing’ is a hard concept to work with anyway, so let’s just name this the way people think of it)
commit --amend --no-edit
commit -am WIP --no-verify
On top of these git aliases, I have a handful of super-short versions too. I use fish abbreviations for this, but based on which shell you use, these might also be aliases or shortcuts.
git select-branch master(actually, mine is a function that auto-detects if the repo uses master or main and switches to the right one)
git push --force(also
gsm && gpl
git commit -a
git commit -am
gh= open the repository’s URL in the default browser at the currently active branch