#OneDevMinute with Ahmad Awais

Go To Previous Git Branch Or Previous Directory via Terminal

4 months ago In Git

Yet Another #OneDevMinute where you'll learn about how easy it is to access the previous git branch, and then again do the same with normal directories in your terminal. Seriously, if you are working in two different directories or in two different git branches, then moving back and forth again and again can be pretty cumbersome. This tip sets you up with cd - or git checkout -. Watch the video to learn more.

git checkout other-branch
git checkout yet-another-branch
git checkout - # Takes you back in the other-branch
git checkout - # Takes you back in the yet-other-branch

cd dir1
cd dir2
cd - # Takes you back in the dir1
cd - # Takes you back in the dir2

P.S. If you like my work, feel free to share it, like it, and subscribe. Peace! ✌️