Moving uncommitted changes to a new branch

Git

Git Problem Overview


> Possible Duplicate:
> Move existing, uncommited work to a new branch in Git

I have some code in branch ABC.

After making some changes to it, i'd like to move all those uncommitted changes into a commit on a new branch ABC_1.

How can this be done please?

Git Solutions


Solution 1 - Git

Just create a new branch:

git checkout -b newBranch

And if you do git status you'll see that the state of the code hasn't changed and you can commit it to the new branch.

Solution 2 - Git

Just move to the new branch. The uncommited changes get carried over.

git checkout -b ABC_1

git commit -m <message>

Solution 3 - Git

Just create a new branch with git checkout -b ABC_1; your uncommitted changes will be kept, and you then commit them to that branch.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJames RaitsevView Question on Stackoverflow
Solution 1 - GitAbizernView Answer on Stackoverflow
Solution 2 - Gitrohit89View Answer on Stackoverflow
Solution 3 - GitCharlesBView Answer on Stackoverflow