Reputation: 55604
I'm new to git, and it says that one of its features is everything is local, so you commit changes when not online.
What happens if you go offline, make several changes, commit etc. And a few minutes later, before youre back online, another person makes changes, some of which are in the same place you've made you're changes. Both are unaware that they've made the same/similar changes. What happens when the changes are pushed to the server? Which changes get "put in"
Upvotes: 1
Views: 326
Reputation: 3995
Git is quite smart, it never let you push if you have unpulled changes.
What would happen in this case is you would have to pull, on this pull git will try to merge your changes with the ones in the server (done at the same time by the other guy).
If it is able to merge the changes automatically, nothing happens. If it is not smart enough it will give you a conflict that you have to resolve, git has a very clever way of expressing the conflicts and they are usually very easy to fix.
Here you have the official manual to fix conflicts : http://www.kernel.org/pub/software/scm/git/docs/user-manual.html#resolving-a-merge
Upvotes: 2
Reputation: 4040
The changes made first get put in. Then when you try to commit your changes, git will try to merge, if git is unsuccessful the commit will return an error and your source files will be marked in the areas where there were conflicts -- you'll see each of the conflicting changes side by side. You have to go through each conflict and select the correct change to commit.
Upvotes: 0
Reputation: 135588
The first one who pushes to the shared repository can push their commits without problem. When the second person tries to push their changes, git detects a conflict and rejects the push. The second person then has to pull the first person's changes first and merge them into their local repository. After a successful merge, person 2 then pushes the merged changes to the shared repository.
Upvotes: 4