Scott Whittaker

Software Engineer

Day job React | side projects Svelte

git - checkout previous branch

Just discovered this little trick to checkout the previous branch you were working on. It allows you to toggle quickly between your last 2 branches…

git checkout -

For example, lets say you are working on master and you create a new feature branch feature/foo

git:(master) git checkout -b feature/foo
Switched to a new branch 'feature/foo'

To quickly switch back to master

git:(feature/foo) git checkout -
Switched to branch 'master'

And again back to feature/foo

git:(master) git checkout -
Switched to branch 'feature/foo'