2

I'm not professional to git, and these days have got some problems when I use git.

There are three files shown below:

a.txt
b.txt
c.txt

When three users try to modify each of these files(Person A : a.txt, Person B : b.txt, Person C : c.txt), there are no problems.

But when, these People simultaneously try to modify a.txt, which is up-to-date file on the remote server, there may be some problems.

Let me give an example.

Person A pushed his modified a.txt to remote server while other Persons still are modifying previous(before Person A push) a.txt.

In this case, Person B, C's a.txt has inconsistent with remote server's new a.txt.

How to resolve this situation? and How people work when they are modifying same file(in above case, a.txt) (I mean workflow)

user7159879
  • 637
  • 2
  • 8
  • 14
  • http://stackoverflow.com/questions/161813/how-to-resolve-merge-conflicts-in-git – McNets Dec 02 '16 at 10:22
  • You [merge](http://stackoverflow.com/questions/161813/how-to-resolve-merge-conflicts-in-git) the files. If the two user modify different parts of the same file, the merge can be done automatically by git, if not, you'll have to select manually for each conflict (paragraph, line, word, ...) which one you want to keep. – Holt Dec 02 '16 at 10:23

1 Answers1

4

That is (in theory) easy. Person A pushed his modified version to the remote. Now Persons B and C have inconsisted versions of a.txt. If they try to push their versions, git will not allow this (commit is possible, as a commit does not go to the remote server).

Before they can push they have to pull changes from the remote server. Git will try to merge them with the local changes. If git failes (because they changed the same lines), Persons B/C need to manually resolve the conflict. Then they can commit again and push to the remote server. Well, only one person can do that. The last one has to do this again (because the remote version changed again compared to the local version).

That is the theory. Most of the times this works quite well.

Seb
  • 1,521
  • 1
  • 12
  • 19