Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create branch from current working tree and reset to HEAD

Tags:

I currently work on a feature that turns out to be bigger than expected, so it's propably the best to create a branch to work on it. So I need to create a new branch from my current working directory and reset the master branch to the current HEAD so that some fixes to the production environment can be done.

Somehow this sounds like an easy task, yet I can't quite figure it out. Possibly due to my lack of sleep.

like image 346
nocksock Avatar asked Jan 18 '10 23:01

nocksock


People also ask

Can I create a new branch with current changes?

You can do a checkout and create a new branch with all local and current changes transferred over.


1 Answers

So, create a working branch:

git checkout -b working_branch 

either commit or stash your changes

git add <files> git commit -m "message" 

OR

git stash 

Go back to master

git checkout master git reset HEAD 
like image 79
Igor Zevaka Avatar answered Oct 28 '22 12:10

Igor Zevaka