Move all new code on Master to a new branch in Git

branch, git

Solution

If you haven't committed yet to the master branch. do a `git diff` to create a patch. create new branch

`git checkout -b new_branch`

and apply the patches using `git apply`

You can follow this question in order to understand better how to create patches from uncommited / unstaged changes

Problem

I'm using Git. I accidentally started doing all of my code changes on Master. How can I create a branch "new_feature" and have all of my changes moved to the "new_feature" branch and off of master?

Original source

Related problems