Exact error message:
hint: You have divergent branches and need to specify how to reconcile them. hint: You can do so by running one of the following commands sometime before hint: your next pull: hint: hint: git config pull.rebase false # merge (the default strategy) hint: git config pull.rebase true # rebase hint: git config pull.ff only # fast-forward only hint: hint: You can replace "git config" with "git config --global" to set a default hint: preference for all repositories. You can also pass --rebase, --no-rebase, hint: or --ff-only on the command line to override the configured default per hint: invocation. I've been using Git for about 10 years now. I don't consider myself a true expert, but I'm very comfortable in the command line and can get myself out of most errors I run into, however this issue has stumped me.
Traditionally my office directly merges feature branches into a main branch then deploys that main branch, this is a continuous delivery pattern that the entire company pretty much follows. Due to some constraints my team decided to take a different approach to release our new app. The team has decided to keep the old code frozen on the main branch with 0 merges, unless there is a production bug. Next, we created a release branch off of main and then merged all feature branches into the release branch. After all features have been developed, the release branch will be merged into the main branch and elevated/deployed. I'm not a huge fan of this approach, it feels like waterfall development to me, but it was a team vote, so I'm trying to make the best of it.
My issue is myself and about half the team have started getting "divergent branch" git errors very consistently. These occur when trying to pull release into a feature branch after a different branches pull request has been merged into the release branch. The other half of the team never sees the errors and can merge, pull, push, etc... like normal. My hunch is this is due to the nonstandard workflow we are using, but I don't know how to prove it. I could also be completely wrong on that hunch, but the workflow is the only thing that's changed since I've started seeing these errors.
I understand what the divergent branch error means and I know how to workaround the issue and resolve it in Git. This question is more why is this happening and why is this happening to only half the team? I've spent a few weeks wondering about it, but I haven't been able to pinpoint why this is suddenly an issue.
Extra information that may or may not be useful:
- There is one Windows developer on the team and they have never seen this issue. The other five developers use OS X and three of us get the divergent branch issue while the other two have never seen it.
My best attempt at diagramming the branching situation (old vs new):
Traditional style at my work:
Main \ various feature branches Current style:
Main(frozen code) \ release(acting like main branch) \ \ \ various feature branches all branching off release I've followed the error message and tried setting my merging strategy to fast forward only and rebase true, but the problem still persists. As for my team, I don't think anyone else has ever touched their Git configurations, so they would all be on the default strategy.
I've tried looking at Stack Overflow and blog posts. These helped me learn how to workaround the issue, but I'm still confused on what the root cause could be. I've also looked at what files are considered diverged using this post. I've had issues finding answers due to my current workflow being different than the traditional workflows blogs and Stack Overflow posts tend to reference.
git versionandgit config -lbetween the ones that get the messages and the ones that don't.... the answer might be there.git pullis to reconcile divergent branches (etiher by merging or by rebasing). Only if only the remote branch has additional commits, the local branch can be fast-forwarded