Paul
Paul

Reputation: 401

Creating a git Branch after changes have been made to master

I started doing work in master - many changes later (no commits) I realized that this work should be done in a separate branch.

Can I create a new branch with my current changes, then discard the changes in master back to its pristine state?

Thanks

Upvotes: 5

Views: 993

Answers (1)

Paul
Paul

Reputation: 401

I figured it out.

while on master:

git branch [new-branch]
git checkout [new-branch]

...continue editing - in my case I committed them...

git add .
git commit -am 'updates'

switch back to master

git checkout master

Branch was in original state before I started making all the changes...

Hope this helps somebody else!

Upvotes: 4

Related Questions