tags:

views:

60

answers:

2

Hey there,

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.

+3  A: 

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
Igor Zevaka
There's no point in doing `git reset HEAD` immediately after a `checkout`. There won't be any changes in the index, checkout of a branch updates the index to the checked out branch.
Charles Bailey
That is a bit of an overkill, assuming you commit in the new branch, the working tree should be clean.
Igor Zevaka
+3  A: 

If you haven't yet made a commit then you don't need to move master, it's already at the current HEAD. You can just checkout a new branch with checkout -b, it doesn't need your working tree to be clean.

E.g.

git checkout -b newtopic

You are now on newtopic and can commit your working tree changes here. master doesn't need to move.

Charles Bailey