DEV Community

Noel Worden
Noel Worden

Posted on

1 1

Git: The Power of the Dash

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.

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

Top comments (1)

Collapse
 
andydangerous profile image
Andy

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

Eliminate Context Switching and Maximize Productivity

Pieces.app

Pieces Copilot is your personalized workflow assistant, working alongside your favorite apps. Ask questions about entire repositories, generate contextualized code, save and reuse useful snippets, and streamline your development process.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay