2

I have a problem with editing one single file (which is called AssemblyVersionInfo) by two persons simultaneously. If first person change its content from version: 1.0.0.244 to version: 1.0.0.245 git just merge these changes and result is version: 1.0.0.245, when it should be version: 1.0.0.246. It looks just like a race condition on variable update without synchronization.

It is possible to force git to show merge conflict if one file was changed on different branches even if its content is identical?

Alex Zhukovskiy
  • 9,565
  • 11
  • 75
  • 151
  • You might consider making changes to the version number via a build or CI process instead of trying to make the source control "knowing" how to update the version for you. – crashmstr Apr 12 '17 at 17:00
  • The short answer is "no". See http://stackoverflow.com/q/41822955/1256452 for the long answer (but it's still "no"...). – torek Apr 12 '17 at 19:59

1 Answers1

1

You could use git merge --no-ff and then set the version correctly. Afterwards you have to commit the merge and the version-changes.

From the documentation:

--no-ff
Create a merge commit even when the merge resolves as a fast-forward. This is the default behaviour when merging an annotated (and possibly signed) tag.

Christoph
  • 6,841
  • 4
  • 37
  • 89
  • So it's not possible to configure it via `gitattributes` or something? My colleges are using different tools which may be not supporting this key while i'd like to ensure that it's not possible to edit file in such way. – Alex Zhukovskiy Apr 12 '17 at 16:36
  • 1
    It seems, this is possible: [here](http://stackoverflow.com/a/2500446/5784831) and [here](http://stackoverflow.com/a/6810687/5784831) – Christoph Apr 12 '17 at 16:46
  • Sorry, but I don't understand how it should be working. For example, I edited 500 files in branch A (including VersionInfo), my friend did the same in branch B, I push my branch into master. Now my friend is going to push his branch. How `no-ff` option will prevent branch from being automatically merge? How git could create a conflict on two files with same content? – Alex Zhukovskiy Apr 12 '17 at 17:48
  • It does not create a conflict because there is no conflict. Git just merges (without commit). Your friend then has to check whether versions are ok. If it is not ok, he can change the version by hand and then commit with the correct version number. If the conflict is caused because the version is not increased automatically, you could use a pre-commit hook (Increase the version every time you commit). That is something we use... – Christoph Apr 12 '17 at 17:56