3

We have a long running feature branch created from develop. A few people have been working on feature(work on sub branches created from feature and merge back to it) for a month, but never sync feature with develop.

I'm trying do git rebase develop on feature today, there are too many conflicts, it seems for each new commit git rebase creates, there are always conflicts, however many of them are not a problem if only comparing the first and last commit.

What's the best way to sync feature with develop in this case? For a long running feature branch like this, what's the best way to keep them in sync? (If I do git rebase develop very often and keep resolving conflicts, is it good ?)

vincentf
  • 1,419
  • 2
  • 20
  • 36
  • 1
    Why are you rebasing? The standard way to do this would be to [`git merge`](https://git-scm.com/docs/git-merge) – Liam Oct 04 '18 at 12:30
  • 2
    I've basically seen [this exact same question today](https://stackoverflow.com/questions/52641860/how-to-resolve-your-conflicts-while-rebasing-your-code) already. I'm not clear why everyone has decided why rebasing all the time is a good idea. rebasing is designed for simple merges to keep your branch clean. Not for complex merges. You can also look into [`git merge --squash`](https://stackoverflow.com/questions/5308816/how-to-use-git-merge-squash) – Liam Oct 04 '18 at 12:34

1 Answers1

6

Why don't you just merge develop into feature? It's a long-running branch, so rebasing does not seem like the right solution.

git merge develop

You will still have to resolve the conflicts, but that can't be helped with long-running branches. Periodic merging seems to reflect your branch setup better than trying to rebase it, which re-writes the commit history.

Adam Millerchip
  • 20,844
  • 5
  • 51
  • 74