GitFlow - Master or Develop branch which to mirror

58 Views Asked by At

I'm new to GitFlow. Should develop branch be a mirror of master branch all the time or the other way around ?

As a background of situation, after doing so many releases (e.g. merge pull request from release branches), there are extra commits on master branch that develop branch don't have. I tempted to delete 'develop' branch and create fresh 'develop' branch.

1

There are 1 best solutions below

0
TTT On

In Git Flow, most of the time develop should be ahead of master, but perhaps in state only. In other words, develop should contain all commits on master except perhaps the merge commits caused by completing a release branch, which is exactly what you're witnessing. After you do the first hotfix branch, all of those commits will be brought into develop at the same time.

You could just ignore those merge commits, but personally I prefer having develop be fully up to date with master. Fortunately there is a simple solution to this, which is, after merging release into master, skip the merge of release into develop, and instead merge master into develop. In this way the new merge commit on master is also brought into develop. Having develop be fully ahead of master in both state and commits is useful for knowing you won't accidentally blow away a hotfix in production when you deploy because someone forgot to merge it all the way down to develop or release.