user941401
user941401

Reputation: 323

Git's Version of Update to HEAD

I'm a newbie at git and want to understand how to collaborate with a few friends on a project using git. My problem is trying to understand how to "updated to HEAD (like in SVN)" in git. I understand git's a bit different, and I would appreciate any help.

So consider this situation. There is Person A and Person B. Person A changes a file by making 1 addition. He then performs:

  1. Commit's on his own branch
  2. Switch to master
  3. pull origin master
  4. git merge personAbranch
  5. git push origin master

So, so far, this works, as on GitHub the repository has been updated with Person A's changes.

Now, assume that Person B during this whole time has been making changes of his own as well. He too, makes 1 addition. What should Person B do "update to HEAD" so that he can commit his changes as well. What Person B has tried is...

  1. commiting his own change to his own branch.
  2. Switching to master
  3. git pull origin master
  4. git merge master ian.

On the fourth line, he always gets a complaint of a conflict. Why?!

Any help would be greatly appreciated.

Upvotes: 0

Views: 737

Answers (1)

Ken Thomases
Ken Thomases

Reputation: 90541

If git is complaining about a conflict, it means that person A and person B (could his name be Ian? ;) have modified the same file and the changes, well, conflict. Either the file is a binary file, for which git can never resolve two different modifications, or it's a text file and the two modifications touch the same set of lines.

You will have to resolve the conflict. You can use git mergetool to help with this.

(Conflicts are not unique to git. They can happen with Subversion, too, for the same sort of reason.)

Upvotes: 1

Related Questions