Danny Lin
Danny Lin

Reputation: 2300

What would happen if there are multiple operations simultaneously in Git?

Say I have a git server. User X wants to add files A, B, C, D, E, and then commit, while user Y wants to add F, G, H, I, J, and then commit.

If they happen to operate in the same time, would it be possible that git add F, G, H, I, J be run during the git add A, B, C, D, E and commit -m 'user X commit' process so that the files added by Y be mixed into user X's commit (especially when files A ~ E are large and take much time to add and commit)?

If it's possible, is there a solution for this?

Upvotes: 0

Views: 214

Answers (1)

Sebastien
Sebastien

Reputation: 1476

First, there is an execution delay between typing in git add and then git commit. So assuming the git add were performed "simlutaneously", the first user who's git commit would be executed would commit all files and the other user would be issued an error to the effect that there is nothing to commit.

This all assumes that both "users" operate as the same "user" on the same directory. Which has nothing to do with the real git workflow where each "user" is it's own user and operate on it's own cloned version of a common repo. The problem you refer to could occur at the git push level. However, the first user who's "push" would be received on the remote repo would be updated as expected and the other user would be issued an error "push denied" since then there would be an inconsistency in the tree and the "slower" user would have to apply his changes on the other user's commit. Which would be easy enough to resolve has it's garanteed there wouldn't be any conflicts.

I suggest you read: http://www.danielmiessler.com/study/git/ or any other git tutorials out there.

If you are talking about a deployment that is version-controlled that many people may acces simulaneously, I strongly recommend to change the workflow so that you use an external repo in which you publish the changes to via push and deploy on the common-used serve via git clone and then git pull:

  user1 local repo git push to --> common repo <-- git clone/pull on common server
  user2 local repo git push to ----^

Upvotes: 1

Related Questions