From 639f0da36ac2781ae4bff736c191f9ac14338eae Mon Sep 17 00:00:00 2001 From: Isabelle Viktoria Maciohsek Date: Sun, 4 Apr 2021 14:13:31 +0300 Subject: [PATCH] Add switch to last branch --- snippets/switch-to-last-branch.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 snippets/switch-to-last-branch.md diff --git a/snippets/switch-to-last-branch.md b/snippets/switch-to-last-branch.md new file mode 100644 index 000000000..baa21a683 --- /dev/null +++ b/snippets/switch-to-last-branch.md @@ -0,0 +1,18 @@ +--- +title: Return to previous branch +tags: branch,beginner +--- + +Switches back to the last branch. + +- Use `git checkout -` to switch back to the previous branch. + +```sh +git checkout - +``` + +```sh +git checkout patch-1 +git checkout master +git checkout - # Switches to `patch-1` +```