Reputation: 2493
I have following structure, and would like to follow "gitflow".
develop
feature/101-my-new-feature
* master
Question: In order for branch feature to have develop branch as parent, would I need to checkout develop branch, prior to create all features? When merging features I want them to be merged towards develop branch.
Upvotes: 0
Views: 100
Reputation: 21938
A very typical way to create a feature branch from develop
is to use git checkout -b
, as hinted at by fredrik in comment.
git checkout -b <name-your-feature-branch-here> develop
where the first parameter is the name of the branch to create, and the second is the point from which the new branch should start (here : develop
)
But as the second parameter can be omitted and defaults to the currently checked out commit/branch, if you have develop
checked you can simply do
git checkout -b <name-your-feature-branch-here>
Also note that the above are the commands to create and checkout your new branch. But you could very well create without checking out with
# from develop branch
git branch <name-your-feature-branch-here>
# or from anywhere
git branch <name-your-feature-branch-here> develop
Lastly, what to do if you just created the new branch from the wrong branch? (let's say you mistakenly thought you were on develop
and went for the short version) Just reset the branch to develop
since you didn't commit on it yet :
git reset --hard develop
Upvotes: 1
Reputation: 1028
Yes, if you are looking to merge back to develop
after your feature is complete, you will have to checkout from that (this isn't strictly necessary from the point of view of Git itself, but from gitflow, it will make it easier).
A simplistic approach:
develop (v1.0)
|
|--> feature-1
|
| changes
|
|<-- feature-1
|
|
develop (v1.1)
Upvotes: 1