TIL: Returning to your previous Git branch
If you're a developer, you've probably experienced the same frustration I have; constantly switching between branches can become tedious, especially when you're deep into work on branch X and suddenly need to make a quick fix on branches Y or Z. The usual workflow involves stashing or committing your current changes, checking out another branch, making your fixes, and then navigating back to your original branch to resume work. Branch names can be particularly cumbersome to type depending on your team's conventions. At my company, branch names follow a specific format that includes the type (feature, bugfix, hotfix), sprint version, ticket number, and a descriptive text. That's a lot to type repeatedly! While some terminal plugins offer branch name autocomplete functionality, I recently discovered something even faster and simpler. The Command git checkout - That's it! Just a hyphen. This immediately returns you to your previously checked out branch, saving countless keystrokes throughout your day. If you're reading this and have other Git productivity tips, please share them in the comments.

If you're a developer, you've probably experienced the same frustration I have; constantly switching between branches can become tedious, especially when you're deep into work on branch X and suddenly need to make a quick fix on branches Y or Z.
The usual workflow involves stashing or committing your current changes, checking out another branch, making your fixes, and then navigating back to your original branch to resume work.
Branch names can be particularly cumbersome to type depending on your team's conventions. At my company, branch names follow a specific format that includes the type (feature, bugfix, hotfix), sprint version, ticket number, and a descriptive text. That's a lot to type repeatedly!
While some terminal plugins offer branch name autocomplete functionality, I recently discovered something even faster and simpler.
The Command
git checkout -
That's it! Just a hyphen.
This immediately returns you to your previously checked out branch, saving countless keystrokes throughout your day.
If you're reading this and have other Git productivity tips, please share them in the comments.