I
I
ince2020-01-10 18:03:19
git
ince, 2020-01-10 18:03:19

How to avoid conflicts in git?

There is a main repository with one file.
Several developers fork this repository and start making changes to their copies.
After that, they send their pull requests to the main repository.
But from the moment when one sends a pull request, someone else has already managed to make changes to this file in the main repository.
And because of this, conflict arises.
I don't want to do it manually every time.
Advise how to solve the problem?
(the file cannot be split into several)
5e189234e1f4c309427674.png

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vladimir, 2020-01-10
@ince

It's not up to you to decide, the developer, before making a pull request, must make it in his branch

git fetch
git rebase origin/master

and then solve all conflicts and only then
The only way to minimize conflicts is to beat the file into pieces.
If a person works in a fork, then he must first pull the changes to his master from the main repository

R
Robur, 2020-01-10
@Robur

If you were sent a pull request with a conflict - send it back, the developer must redo it.
If conflicts are constantly pouring in, this is a reason to reconsider the work, or the pull requests are very large, or the code is mixed into noodles so that each change affects many areas, or the tasks are such that developers make changes in the same place.
This needs to be found out and corrected.

V
Vladimir Korotenko, 2020-01-11
@firedragon

Show the file. Although, in general, it is worth organizing the work somehow. For example, tell developers to work on one atomic unit at a time.
For example, only 1 function was changed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question