When I was first starting out in software engineering, it felt like there was a never-ending barrage of tooling to learn. After more than a decade in CLI environments, I still find myself constantly learning new features and fun facts - but it’s fairly rare that I learn something new that I end up using day-to-day.
I wanted to share some things I learned at relatively late stages in the game that ended up being significant productivity boosters for me - perhaps some of them are well-known, but in the spirit of this XCKD, I hope that someone reading this might pick up something new.
You can use
-
everywhere you can use a ref in a git command. I very often usegit checkout master git pull git checkout - git merge -
(Of course that’s all aliased and I have other flags in there too, but that’s the gist)
Same for
cd -
. Nice if you want to go to/etc/blah
, and then back to where you were.You can also use
pushd
andpopd
which will push and pop directories from a stack, if you need to do something more complex.Also, if you want to switch faster between branches, slap this in your
~/.gitconfig
under[alias]
:co = !git checkout $(git for-each-ref refs/heads/ --format='%(refname:short)' | fzf)
Presuming you’ve got
fzf
installed, you can nowgit co
(co = checkout) to get a menu with fuzzy find capabilities to switch between branches. Nice if branch names are long/similar/only-different-at-the-end.fzf
is dope.