1

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.

7
  • Can you please edit your question to include the exact error message from Git copied and pasted into a code block? I'm unsure what error message this is, and I work on Git, so being able to see the exact error message would help us all provide a helpful response. Commented Dec 26, 2023 at 21:06
  • "[…] and need to specify how to reconcile them. You can do so by running one of the following commands sometime before your next pull: […]". Sounds like one half of your team configured their clients as instructed and the other half ignored the hint given by the message. See also this question which is very similar in nature (only claiming 20 years of experience with Git) Commented Dec 26, 2023 at 21:57
  • First off thank you for the help! I've played around configuring all of these merge options, the error message itself is very clear and straightforward my fault should have posted that in the original question. No matter what I configure I still get divergent branch issues though. Not sure if your comment is implying the half of the team with the divergent branch issues is the incorrect half or the other half but if its the latter I can confirm setting my merge strategy doesn't change my problem. That adds to the confusion since the error message seems to say it should fix my issues. Commented Dec 27, 2023 at 0:40
  • 1
    check git version and git config -l between the ones that get the messages and the ones that don't.... the answer might be there. Commented Dec 27, 2023 at 8:02
  • If the local branch (destination) and the remote branch (source) have different commits, you have in fact, by definition divergent branches. 50% of the work of git pull is 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 Commented Dec 27, 2023 at 8:48

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.