Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Two people working on a file at the same time in git [duplicate]

Tags:

git

github

Possible Duplicate:
How git works when two peers push changes to same remote simultaneously

I'm kinda new to git and me and a friend want to do some collaborative developing with git. I got the whole pull and push system down somewhat, now I have a question.

I want to work on file test.php and I pull for new changes. Nothing. I edit it and want to push it, but in this time my friend edited and pushed it. What happens now? How are these conflicts solved?

Thank you!

like image 200
mishmash Avatar asked Dec 14 '11 17:12

mishmash


People also ask

Can two people work on the same file in GitHub?

So you can also have collaborators working on different lines within the same file and GitHub will be able to weave those changes into each other – that's it's job! It's when you have collaborators working on the same lines within the same file that you can have merge conflicts.

Can two people edit the same file in git?

From what I understand, the benefit of Git is that two+ people can work on the same file that they pulled and make changes to it locally.

Can two people work on the same branch git?

Multiple people can work on the same branch at the same time. When you pull (or have the other person push) their changes to you git will merge the changes together resulting in a branch with both of your changes.

What happens if two people push to git at the same time?

If server detects a conflict when someone pushes data (and if two users are doing this "simultaneously" one of the pushes will be conflicting, because it will be applied only after the other one completes), the server will reject it, and the unlucky user shall then resolve conflicts and try to push again.


1 Answers

the procedure should be the below:

  • pull the file
  • edit it
  • commit it(it commits to your local repository)
  • pull it again (if there are any conflict you will Be notified) in that case you can solve it executing the below command(GitBash on your repository working folder):

    git mergetool

it will run the merging tool you got configured in your .gitconfig file

after that you can push your changes

like image 147
Massimiliano Peluso Avatar answered Sep 27 '22 02:09

Massimiliano Peluso