0

Possible Duplicate:
In git merge conflicts, how do I keep the version that is being merged in?

I have two local git branches on my machine - a branch called "v2" and a branch called "master".

I'd like to merge the "v2" branch into the "master" branch. When I perform the merge, there are a number of conflicts that I must resolve one by one.

The ones I'm having trouble with are where the "master" branch file has additional code that the "v2" branch does not. How do I keep the "master" branch file and not the "v2" branch version of the file?

The options presented to me by Git Tower for these types of conflicts are:

  • Mark FILENAME as Manually Resolved
  • Resolve by Keeping FILENAME
  • Resolve by Deleting FILENAME
  • Restore Their Version of FILENAME
  • Open in External App

From my understanding, the option to "keep" the file meant keeping the "v2" version (the one being merged in) and "deleting" the file meant not adding the "v2" version (but instead keeping the existing "master" version). When I used this option, though, it actually deleted the file altogether from the repo.

How do I keep the "master" branch file and not the "v2" branch version of the file for these types of conflicts?


EDIT: I'm merging v2 into master while master is checked out and the head branch.

Community
  • 1
  • 1
Tim Jahn
  • 1,154
  • 7
  • 16
  • 29
  • Are you merging v2 into master (`git merge master` while v2 is checked out) or master into v2 (`git merge v2` while on master) -- this is important for the meaning of "keeping" and "restoring theirs" – Nevik Rehnel Dec 14 '12 at 17:55
  • I'm merging v2 into master while master is checked out and the head branch. – Tim Jahn Dec 14 '12 at 17:58

1 Answers1

0

Since you're merging something else (v2 a.k.a theirs) into master, you can "keep" the file (which refers to "ours"), leaving the file as it is on master.

Remember that git repos are self-contained; you can simply test something like this by making a backup (copy the whole containing folder of your repo somewhere else, or ZIP/TAR it up), and try it out. If it doesn't produce the result you thought, and you can't undo it with git tools, simply delete and restore your backup! :D

Nevik Rehnel
  • 49,633
  • 6
  • 60
  • 50
  • Ok, that makes sense. For conflicts where the "v2" version is the one that I want to keep, I am presented with the options to either "keep", "delete", or "Restore Their Version of FILENAME". Would I want to do the restore option then? – Tim Jahn Dec 14 '12 at 18:37
  • @TimJahn that would be "Restore theirs". When merging or rebasing, "ours" refers to the "home" branch (in a merge, the one you're currently on), and "theirs" to the other branch (in a merge, the one you're merging in on your base) – Nevik Rehnel Dec 14 '12 at 20:13
  • That's what I thought (I understand the idea of ours vs. theirs), but the "Restore Theirs" option doesn't resolve the conflict though in Git Tower for me. Any ideas? – Tim Jahn Dec 14 '12 at 20:28
  • dont use git tower :D git is very powerful. I don't use anything but gitk to visualize long histories, and eclipse for big projects to show changes inside the IDE. But anything meaningful like merges i do with git itself – Nevik Rehnel Dec 14 '12 at 20:56
  • Telling me not to use a piece of software doesn't answer my question about how to do something in that piece of software... – Tim Jahn Dec 14 '12 at 20:59
  • That's why it's a comment, not an answer :P I don't know git Tower at all (hadn't even heard of it before your question) ;) – Nevik Rehnel Dec 14 '12 at 21:31