Reputation: 286
I have two main branches: master
and develop
.
My usual workflow on a new feature is:
git checkout -b <myfeature> develop
git commit -a -m "<message>"
git checkout develop
git merge --no-ff <myfeature>
git branch -d <myfeature>
git push origin develop
Now I need to work on a new feature that requires the current feature. My new workflow would be:
git checkout -b <myfeature> develop
git commit -a -m "<message>"
git checkout -b <newfeature> <myfeature>
git commit -a -m "<message>"
git checkout develop
git merge --no-ff <myfeature>
git branch -d <myfeature>
git push origin develop
git checkout newfeature
git commit -a -m "<message>"
git checkout develop
git merge --no-ff <newfeature>
git branch -d <newfeature>
git push origin develop
Is this a proper workflow? Is there any repercussions to deleting the branch in step 10 (i.e. does it orphan newfeature?)?
The original guidelines were from Vincent Driessen's A successful Git branching model. I also read Create a branch in Git from another branch, but it doesn't really get into deleting the branch that spawned the new branch.
Upvotes: 1
Views: 2689
Reputation: 61
Nothing wrong with that.
Just be sure to manage those states with a little caution. Lets say. You work on A and clone B. But you need to do some changes on A after business found something they want to have changed. If you push A and want those changes now in B, git merge might result in duplicate commits. Instead use git rebase.
I am working solely with trunk-based development. https://trunkbaseddevelopment.com/
Upvotes: 1
Reputation: 26066
Is this a proper workflow?
That depends on what you want to achieve. There are many possible workflows.
Is there any repercussions to deleting the branch in step 10 (i.e. does it orphan newfeature?)?
Branches are just pointers to a commit, they do not depend on each other. Deleting a branch removing that entry point to the graph, but it does not remove the commits by itself. As long as you have a way to go back to that commit from another branch, the commits will never be removed.
Upvotes: 5