Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to minimize git merge conflicts?

Our company uses git to to keep track of document/code changes, with several people making changes and pushing to a central repo. Most of them are novices when it comes to git or command line tools in general. For them we have scripts to update or publish their local repo after making changes.

Are there any workflows that work better for situations like these, to minimize merge conflicts occurring that have to be sorted out by someone more experienced with git?

like image 512
bluegray Avatar asked Nov 18 '12 20:11

bluegray


People also ask

How do you reduce a merge conflict?

Split the problem up into small enough pieces that you can quickly modify files and push them back to trunk. The shorter lived your branches are, the less chance there will be of merge conflicts. Even then, at some point two people will edit the same file at the same time through no fault of their own.

What causes merge conflicts git?

Git can handle most merges on its own with automatic merging features. A conflict arises when two separate branches have made edits to the same line in a file, or when a file has been deleted in one branch but edited in the other. Conflicts will most likely happen when working in a team environment.


1 Answers

Git is not a replacement for proper development practices. It will not code better for you.

If two developers are touching the exact same code, git has no way of making their job easier, if it's a merge conflict, it'll be one no matter if you're on a branch or not.

Short term solution: use proper local and remote branches to encapsulate work on different features. Use branch diffs (or github pull requests) to review feature sets and help go over diffs and conflicts.

Long term: fix your code, adapt your it to your team and vice versa, and use proper development practices.

like image 175
Yuval Adam Avatar answered Oct 06 '22 00:10

Yuval Adam