21

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?

Stefano Ortisi
  • 5,288
  • 3
  • 33
  • 41

1 Answers1

29

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.

Daniel Hilgarth
  • 171,043
  • 40
  • 335
  • 443
  • 1
    Can you please explain 'You normaly don't merge feature branches into develop'? I just ran `git flow feature finish ` and it outputted precisely that. – webXL Aug 21 '13 at 03:08
  • @webXL: My answer was pointed at his question to repeatedly merge changes from the feature branch into develop. That's not what you do. What you do however, is to merge the feature branch into develop *once* it is finished. So you have multiple merges from develop to feature (or rebases of feature on top of develop) and at the end of the feature branch, you have a single merge from feature to develop. Does this make sense? – Daniel Hilgarth Aug 21 '13 at 06:20
  • @DanielHilgarth Yes, thanks for the clarification. I was pretty sure that was the case, but the answer just didn't seem correct. – webXL Aug 21 '13 at 19:53
  • @webXL: I updated my answer in the hope to be a little bit clearer. Thanks for pointing this out. – Daniel Hilgarth Aug 21 '13 at 20:29