git list previous branch

git list previous branch
Photo by @jachan_devol / Jachan DeVol

In git, how do I go back to the previous branch I was just on? I've got a memory of a fish and easily forget which branch I was on previously- how do I switch back? Also, is it true fish have short memories and what if they're drunk?

An aswer to finding the name of the previous branch you were on is:

git name-rev @{-1} --name-only

Will show you the last branch you were on in terminal.

Source: https://stackoverflow.com/a/59766367

See also Scott Stafford's longer post wish alias setup examples:

List your most recently-used branches using Git
Set up a git alias that uses the reflog to show what branches you have most recently been using
Collect recurring payments with Subscribie