Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 492
Paul Avatar asked Oct 09 '22 01:10

Paul


1 Answers

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!

like image 87
Paul Avatar answered Oct 12 '22 20:10

Paul