0

I am trying to sync code between two streams of work. So I have written a script to auto-merge the changes from master to a developer2 branch. This is working fine until the profile1.xml changes in developer2 are increasing than profilex1.xml in master. So I end up getting conflicts all the time. Is there any to resolve these conflicts through script with losing changes on both ends?

script:

  git checkout origin/master
  git pull
  git checkout origin/developer2
  git merge master
SwissCodeMen
  • 4,222
  • 8
  • 24
  • 34
kumar
  • 127
  • 1
  • 11
  • Does this answer your question? [Can git be made to mostly auto-merge XML order-insensitive files?](https://stackoverflow.com/questions/37849771/can-git-be-made-to-mostly-auto-merge-xml-order-insensitive-files) – Renat Feb 28 '21 at 18:19
  • @Renat I have tried git merge --union master I am getting an error as it does not recognize Union error: unknown option `union' – kumar Feb 28 '21 at 18:43
  • Regardless of what you do to tell `git` to attempt an auto-merge, there will be times it will fail. There are times that there is just no way to know what the right result of the merge is, like when two recent commits make a different change to the same line of code. In this case, there's no way to know algorithmically which is correct. In fact, neither may be correct. One has to look at the context in which each change was made, understand why the change was made, and then decide if/how to apply both changes to the one line of code. That can be an almost arbitrarily complicated operation. – CryptoFool Feb 28 '21 at 22:33
  • The union merge option is available only in (a) `.gitattributes` and (b) the `git merge-file` command. It is not an option you can supply to `git merge` directly. But note that my answer points out that union merge is not smart enough to deal with XML in general. – torek Mar 01 '21 at 03:23

0 Answers0