Is there any way to go back to the last branch in git?

4

The title says it all. Around and half we use git as follows:

git checkout branch_x
git checkout branch_y
git checkout branch_x

x can be master , or any feature branch any.

I'd like to know if there is any way to get back to the last branch used. Does git have something equivalent to cd - for directories in the command line?

    
asked by anonymous 16.11.2015 / 16:53

1 answer

4

I think you just need to do the following on the command line:

git checkout @{-1}

As exemplified in these answers .

    
16.11.2015 / 17:04