1

My company just wants to switch from Microsoft VSS to Git with KDiff3, and we ran into a problem.

As known, Git tracks contents instead of files. That is a great feature, and we love that. But it happens that two different parts of the same file has to be editied by two programmer at the same time. Git tries to do a diff and a merge and if it can insert both editing into the final, it does that. But there are many times when these two editings are exclusive to each other.

Example: Original version:

<Grid>
  <Grid.RowDefinitions>
   <RowDefinition />
   <RowDefinition />
   <RowDefinition />
  </Grid.RowDefinitions>


</Grid>

Edit #1:

<Grid>
  <Grid.RowDefinitions>
   <RowDefinition />
   <RowDefinition />
   <RowDefinition />
  </Grid.RowDefinitions>

 <Button Content="Click here" Grid.Row="1" />
</Grid>

Edit #2:

<Grid>
  <Grid.RowDefinitions>
   <RowDefinition />
   <RowDefinition />
   <RowDefinition />
  </Grid.RowDefinitions>
 <CheckBox Content="Check it!" Grid.Row="1" />

</Grid>

As you can see, these two editions are not creating a merge conflict, but - if you are somewhat familiar with WPF, XAML - the Grid.Row attributes will "kill" each other, resulting an awkward visual.

So this "conflict" is not in the text, but in the logic. Of course, this is a simple example, and with strict coding style it can be solved. But we are changing the version control system, so we have lots of codes like this, so we are simply not capable to rewrite the whole project by a new coding style.

Is it possible to tell Git or KDiff3 to just check if the files themselves are different, and that means conflict instead of the content?

Thanks, SanTa

Sándor Tamás
  • 193
  • 1
  • 1
  • 10
  • you can check [here](http://stackoverflow.com/questions/5074452/git-how-to-force-merge-conflict-and-manual-merge-on-selected-file) it seems related – Frederic Henri Sep 14 '15 at 13:37

1 Answers1

1

There are situations where text files should not be compared for merge due the nature of the file, such as a database file or a code generated file. With that thought one could make the files appear to git as binary data files which are not compared.

In the .gitattributes file specify this to setup a compare ignore type checkin situation:

*.xaml binary

To quote Git - Git Attributes

Some files look like text files but for all intents and purposes are to be treated as binary data. For instance, Xcode projects on the Mac contain a file that ends in .pbxproj, which is basically a JSON (plain-text JavaScript data format) dataset written out to disk by the IDE, which records your build settings and so on. Although it’s technically a text file (because it’s all UTF-8), you don’t want to treat it as such because it’s really a lightweight database – you can’t merge the contents if two people change it, and diffs generally aren’t helpful. The file is meant to be consumed by a machine. In essence, you want to treat it like a binary file.

ΩmegaMan
  • 29,542
  • 12
  • 100
  • 122