Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: Will merging master into a topic branch often avoid conflicts later on?

Lets say for the sake of argument that we don't care much about history.

If I have a master branch that is being updated somewhat often and I have a shared topic branch that is rather long lived, will regularly merging master-> topic branch (and resolving conflicts as they arise) allow for a smooth merge of the topic branch -> master later on?

like image 504
Ben Avatar asked Oct 05 '10 01:10

Ben


People also ask

What happens when you merge master into a branch?

If the merge request is approved without conflict, the GitLab master will merge into the branch, and both the master and release branches will be in sync. The source code and sample project used for these examples can be found on the gitlab-made-easy project page on GitLab.

Is it possible to avoid merge conflicts?

creating branches. creating pull requests. Avoid allowing pull requests to become stale. Make sure you're not changing the same lines of code before merging a prior change.

What happens when you merge git branches?

Merging Branches. Once you've completed work on your branch, it is time to merge it into the main branch. Merging takes your branch changes and implements them into the main branch. Depending on the commit history, Git performs merges two ways: fast-forward and three-way merge.


1 Answers

What you're saying sounds uncontroversial - if you regularly merge (backport) changes from the main branch into a side branch, then, when the time comes to merge your side branch back into the main, you won't have as much work to do.

Of course, right? Over time, your branches diverge. And how you write your code today depends on how you wrote it yesterday. The more your branches have diverged today, the more they will diverge tomorrow.

Say that in the main branch you refactor some code. Say that in the side branch you have to implement a new feature that uses the code that was refactored. If you write that new feature before you merge (backport) the refactoring changes, then, when you want to port the new feature to the main branch, you will either have to a) add back into main the pre-refactored code or b) refactor the new feature. Whereas if you had already merged (backported) the refactoring, your new feature can be merged into main without all that work.

like image 140
Ladlestein Avatar answered Sep 28 '22 02:09

Ladlestein