Add command for git checkout previous branch (#25133)

This commit is contained in:
Edy Ionescu
2019-01-20 22:30:19 +02:00
committed by Tom
parent 7a23e18939
commit 3cfe00eafd

View File

@ -22,6 +22,13 @@ git checkout BRANCH-NAME
```
Generally, Git won't let you checkout another branch unless your working directory is clean, because you would lose any working directory changes that aren't committed. You have three options to handle your changes: 1) trash them, 2) <a href='https://guide.freecodecamp.org/git/git-commit/' target='_blank' rel='nofollow'>commit them</a>, or 3) <a href='https://guide.freecodecamp.org/git/git-stash/' target='_blank' rel='nofollow'>stash them</a>.
### Checkout Previous Branch
To checkout previous branch, run the command:
```shell
git checkout -
```
`git checkout -` is a shorthand for `git checkout @{-1}`.
### Checkout a New Branch
To create and checkout a new branch with a single command, you can use:
```shell