I know that if I’m working away in a branch I can create a new branch and all my commits will go to the new one. But what if I’m working along, I’ve made some commits, still working, and then realize a need a new branch, including the commits I’ve already made (but not pushed to origin). Is there a way I can get everything into a new branch?
Share
Sure, do the following:
This creates a new branch from the current HEAD. Then:
This stores the current changes away for the moment. Then:
Go back to the former branch, and:
This rewinds one commit off the end of
former_branch(use whatever you like to point to the commit you want to go back to, maybeorigin/masteror something). Finally:and carry on working.