I'm starting using git flow and I understand that doing:
git flow feature start my-feature
git flow feature finish my-feature
I create a feature and then, when i've finished my changes, I merge it with the develop branch. The finish flow command literally delete the feature branch after the merge action.
My question is: is there any way using git flow to merge my feature with develop without deleting it after merge.
And my second question would be: is this workflow correct? I mean, is it right keeping alive feature branches while merging with develop, just to update the 'main' branch with some changes and keeping to work on the feature branch?
When you're done with a branch and it has been merged into master, delete it. A new branch can be made off of the most recent commit on the master branch. Also, while it is ok to hang onto branches after you've merged them into the master they will begin to pile up.
More technically, this is the first commit reachable from both branches. This commit is called the merge base. Git then calculates two diffs — from the merge base to the first branch, and from the merge base to the second branch. To form the merge commit, Git applies both diffs to the merge base.
When you perform a merge, you effectively merge one branch into another—typically a feature branch or bug fix branch into a main branch such as master or develop. Not only will the code changes get merged in, but also all the commits that went into the feature branch.
You can always reuse that branch if you'd like or remove it. In Bitbucket Cloud we wont' remove the branch after a pull request is merged unless you use the "Close branch" checkbox during pull request creation.
Simply use git flow feature finish -k my-feature
Reference: https://github.com/nvie/gitflow/wiki/Command-Line-Arguments
About your second question:
You normally don't merge feature branches repeatedly into develop
. You merge develop
into the feature branches (i.e. the other way around) or rebase the feature branches onto the HEAD
of develop
(recommended). The only time when you merge a feature branch into develop
is when you finished the development of the feature.
If you merge feature branches into develop
you completely remove the benefit of having a feature branch and you just could have developed directly on develop
.
If you feel you have the need to merge from a feature branch into develop
you most likely made changes that are not directly related to that specific feature and should have been made in develop
in the first place.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With