Say I have a branch named feature that has been branched off master. Both, developer1 and developer2 checkout feature. developer1 commits a change to feature and pushes it. Then developer3 pushes something to master. At this point master and feature diverge, each having a separate commit.
What’s the right way to go about getting the latest from master into the feature, if there are conflicts? Should I rebase master into the feature, or merge it in?
EDIT:
I should mention that in this case I would not want to rewrite the history on developer2. Because that would be bad. Right?
Considering
featurebranch is already shared, it shouldn’t be rebased onmaster(as it changes its – shared – history).A simple merge from
mastertofeaturewill be enough (without speculating as whydev3pushed tomasterin the first place).As Adam Dymitruk comments, this is called a “back-merge”, and, depending on the role you attribute to
master, it is questionable: ifmasterrepresents the stable production state, you should merge tomaster, not frommaster.But again, my answer made no assumption on said role.
This is why the famous git-flow illustrates in its blog post merges which are coming to master (from, for instance, an
hotfixbranch, as I commented earlier)