From 3cfe00eafd9fe379e72cd267ece476a588b45abd Mon Sep 17 00:00:00 2001 From: Edy Ionescu Date: Sun, 20 Jan 2019 22:30:19 +0200 Subject: [PATCH] Add command for git checkout previous branch (#25133) --- guide/english/git/git-checkout/index.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/guide/english/git/git-checkout/index.md b/guide/english/git/git-checkout/index.md index 71b57e5c49..b659ebbcbd 100644 --- a/guide/english/git/git-checkout/index.md +++ b/guide/english/git/git-checkout/index.md @@ -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) commit them, or 3) stash them. +### 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