This week I racked up another nugget of git knowledge. The beauty in this one is its simplicity.
Have you ever been bouncing back and forth between branches and wished there was a more efficient way than typing out the branch name each time (even with tab complete)? I present you with:
git checkout -
That command will checkout your previous branch. But, that's not the only git command that accepts the dash, it can also be used with rebase, merge, and cherry-pick.
- AND -
After I shared this in my engineering Slack channel, a colleague pointed out that it can be utilized in file tree navigation:
Talk about a game changer! Now traversing backwards can be done with a few less keystrokes.
This post is part of an ongoing This Week I Learned series. I welcome any critique, feedback, or suggestions in the comments.
Top comments (1)
This is one of my favorites. I use it ALL THE TIME!