this post was submitted on 22 Jul 2024
72 points (98.6% liked)
Programming
17305 readers
259 users here now
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Rules
- Follow the programming.dev instance rules
- Keep content related to programming in some way
- If you're posting long videos try to add in some form of tldr for those who don't want to watch videos
Wormhole
Follow the wormhole through a path of communities !webdev@programming.dev
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
You can use
-
everywhere you can use a ref in a git command. I very often use(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.I have fzf-git for all of that, but honestly I don't ever use it, as I'm hardly ever switching between branches and tab complete is enough for me in most cases.