Reputation: 10403
I started a new feature using Git Flow (feature A) but haven't committed any of my changes yet.
I then needed to create a new feature (feature B) but I don't want it to include my uncommitted changes from feature A.
I can't workout why the new feature didn't begin from the current state of the Develop branch! It includes all of my changes from feature A which haven't yet been committed.
Upvotes: 1
Views: 133
Reputation: 3687
If you are currently on branch featureA
with some uncommitted changes and you want to create new branch which does not contain the uncommitted changes, try the following:
git stash
git checkout -b featureB
//now in branch 'featureB` you will no longer have the uncommitted changes
//in order to continue your work on 'featureA':
git checkout featureA
git stash pop
Upvotes: 1
Reputation: 174457
That's normal behaviour in git and has nothing to do with git flow:
When you switch (a.k.a checkout) a branch and you have uncommitted changes in your working directory there are two possible scenarios:
git flow feature start <name>
does exactly that: It creates a new branch and checks it out. Because there are no conflicts scenario 1 happens.
Ask yourself this:
If the uncommitted changes wouldn't remain in the working directory after switching your branch, where should they go instead?
As Thomas correctly points out, git stash
can help you here. Or you could simply commit the changes to the branch of feature A, because you are supposed to commit often anyway.
Upvotes: 2