0

i am try my first merge with git (i thought it will be easier with git than with svn - don't know why). At the moment i use egit (eclipse) and it's merge tool. What i'am missing is the function to tell git that for a given file my local version is the new truth (like copy all from left to right) - i read this

Is there convenient way to overwrite a complete file with my local version? I tried just to save and "add to index" in merge tool but then all the marker "HEAD<<<<<" are also saved :-P. So how to tell merge tool or oher tool "i am fine with left side - take it" (without any change)?

Community
  • 1
  • 1
dermoritz
  • 12,519
  • 25
  • 97
  • 185
  • `git checkout --ours path/to/file`. But then, what's the point of merging if you only use your version? – knittl Aug 28 '14 at 12:10
  • this is used only for some files - git detects conflict, i want to merge "nothing" for some files and search for a convenient way to this. It would be fine if i could cover all those use cases with one gui tool. switching the tools for each use case would be a nightmare. – dermoritz Aug 28 '14 at 12:19
  • Do you want to resolve all conflicts in a file with your version, or do you want to have the resulting file to be 100 % identical to your version? – knittl Aug 28 '14 at 12:27
  • the latter - want overwrite complete file – dermoritz Aug 28 '14 at 12:41
  • For egit, see the answer on [How to do an “ours” merge using the Eclipse git merge tool?](http://stackoverflow.com/a/11683928/112968) – knittl Aug 28 '14 at 12:57
  • thanks in meantime i found out myself this is working: "So when the left section is already good, just make a small modification, undo it and then save. The modification is necessary because save is not available from the beginning." - if you create an answer with it i will accept – dermoritz Aug 28 '14 at 13:04

1 Answers1

1

What you want to do, is to use your (ours) side of the merge for the complete file. With command line Git this can be done via git checkout --ours -- path/to/file.

With egit the question How to do an “ours” merge using the Eclipse git merge tool? has the answer (credits go to robinst):

In the editor of the merge tool, you can edit the left section.

After clicking on Merge Tool, select the "HEAD" option in the dialog that appears, then the left section will contain the same content as HEAD.

So when the left section is already good, just make a small modification, undo it and then save. The modification is necessary because save is not available from the beginning.

Community
  • 1
  • 1
knittl
  • 246,190
  • 53
  • 318
  • 364