Git: Turn current master into branch and keep uncommitted changes

I'm working on my current master and have done quite a few changes which are as of now neither locally nor remotely committed. However, I am ready to commit them. Before doing so I would like to turn the current master without these uncommitted changes into a new branch but I am not completely sure what the right procedure for this is. My first idea was to do a clean clone in a different directory

git clone REPO

and then initialize a new branch from the current master

git checkout -b OLD_MASTER

and then commit. Then go back into the other clone which contains the uncommitted changes and commit them. But that seems unclean to me. What is the right way to achieve my goal?

--------------Solutions-------------

You can create the branch and go back to master:

git stash
git checkout -b old_master
git checkout master
git stash pop

But don't you want a tag instead?

git tag old_master

Category:git Time:2017-12-06 Views:1
Tags: git

Related post

Copyright (C) pcaskme.com, All Rights Reserved.

processed in 0.602 (s). 13 q(s)