loading...

Git: The Power of the Dash

noelworden profile image Noel Worden ・1 min read

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:

cd -

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.

Posted on by:

noelworden profile

Noel Worden

@noelworden

Software Engineer in Boulder, CO - Writing code and getting strategically lost in the mountains

Discussion

pic
Editor guide
 

This is one of my favorites. I use it ALL THE TIME!