Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git hotfix merging to master and master to develop

Tags:

git

merge

If I have two branches: master and develop. All the releases come from the master branch and all features are developed from the develop branch.

If I create a hotfix branch from master and then merge it back to master I think I have two options from there:

  1. Merge to master and then to develop
  2. Merge to master and master to develop

My question is what is the difference and what kind of problems I might have going with either one?

like image 619
Marti Markov Avatar asked Feb 08 '17 09:02

Marti Markov


People also ask

Does git merge master change master?

git merge master will update your current branch with the changes from your local master branch, the state of which will be that of when you last pulled while on that branch.

How does hotfix work in git?

Properties of the Gitflow hotfix No feature enhancements or chores are allowed on the Gitflow hotfix branch. The hotfix branch merges into both master and develop branches when its lifecycle ends. The hotfix branch is deleted after it is merged or rebased into master and develop branches.


1 Answers

In theory, there should be absolutely no difference.

Once you've merged the hotfix branch in to master, master and the tip of the hotfix branch are at exactly the same point.

So whether you merge master or hotfix in to develop, you end up with the same outcome.

Having said that, I personally think you should go with option 1.

With master being for release only, I feel you should never merge from master back in to develop, only from develop in to master.

Keeping this flow one way helps keep things in order. You know in your head you can't make any changes directly on master, as you won't have a way of getting them back in to develop. You either have to hotfix and merge in to both, or create a feature on develop.

Hope that helps!

like image 87
Matthew Hallatt Avatar answered Oct 11 '22 05:10

Matthew Hallatt