79704843

Date: 2025-07-17 12:53:11
Score: 1
Natty:
Report link

Instead of using git merge, use git rebase to reapply your commits from the diverged branch (feature) onto the updated main branch.

Switch to the diverging branch and follow the below commands:

git checkout feature #Switch to the diverging branch
git rebase --onto main <common-ancestor> feature #Rebase onto the updated main
git merge-base main feature #You can find the common ancestor using this command
git rebase --continue #Resolving conflicts

If the branch isn't public/shared the try force-align history using the below command

git rebase -i main

Note : This approach rewrites history, so only do this on branches that are not shared or on feature branches, not protected ones.

After rebasing, if you had already pushed the feature branch before, you’ll need to force-push

git push --force-with-lease

Finally use the below commands as a clean and effective way to resolve diverging branches after git lfs migrate.

git checkout feature
git rebase main

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (1):
Posted by: babin_joe