Igor Medeiros
Igor Medeiros

Reputation: 4126

Git checkout <latest branch you were working on> command

Is there a command to permit checkout the last branch? Like:

git checkout --recent

or

git checkout --previous

The idea is when you switch branch too often you it's easy to forget the branch you were working before the current one. Also if there's a way to set a alias for this that would be valide.

Upvotes: 5

Views: 394

Answers (1)

Bucket
Bucket

Reputation: 7521

What you're looking for is -

git checkout -

For example, say you're on branch foo, and there exists a branch bar.

* foo
bar

Check out bar

> git checkout bar

foo
* bar

Going back to foo

> git checkout -

* foo
bar

The - "shortcut" also works for the cd and ls commands from within a bash terminal.

Upvotes: 8

Related Questions