From 951e37cc2ec5340956f02445a66d3e3af08f462a Mon Sep 17 00:00:00 2001 From: Justin Whear Date: Thu, 14 Aug 2014 10:41:04 -0700 Subject: [PATCH] Use `branch` instead of `checkout -b` Using `checkout -b` to create a new branch only to immediately checkout the previous branch is kind of pointless. --- README.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4f9d249..2678b3e 100644 --- a/README.md +++ b/README.md @@ -192,12 +192,10 @@ Since rebasing **replaces the old commit(s) with a new one**, you must force pus ## I committed to master instead of a new branch -Check out a new branch, then return to your master branch +Create the new branch while remaining on master: ``` -(master)$ git checkout -b new-branch -(new-branch)$ git checkout master -(master)$ +(master)$ git branch new-branch ``` Find out what the commit hash you want to set your master branch to (`git log` should do the trick). Then reset to that hash. @@ -209,6 +207,12 @@ For example, if the hash of the commit that your master branch is supposed to be HEAD is now at a13b85e ``` +Checkout the new branch to continue working: + +``` +(master)$ git checkout new-branch +``` + ## I made several commits on a single branch that should be on different branches