0

I'm fairly new to git so sorry for what will probably not be a 100% clear.

I am working with compiled files (more precisely .acd files from Rockwell for Studio5000 in PLC industrial automation). I'm pretty sure the format of the file is not important. We want to work on project with multiple users. We are using Git as a centralized server and the PLC's brand merge tool (example in this case is Rockwell). We have setup Rockwell's Merge tool as a MergeTool in TortoiseGit and everything is "mostly" going fine.

However, when we do a pull to refresh a local repo, conflicts are 100% to occur because the file is not a .txt file with which Git usually work. The problem is that when we pull (the conflict occurs) and we tell Git we want to merge, it modifies the local file (I'm guessing by putting THEIRS and OURS a little bit everywhere in the file) even though we don't want to resolve the conflicts this way and it corrupts the file for its default reader. The files BASE, REMOTE(THEIRS) and LOCAL(OURS) only appear when we use TortoiseGit's Edit Conflict (they do not automaticly appear when we specify we want to merge the 2 versions).

My problem is that un exeperienced and/or unattentionned person can easily push the corrupted file on the server because resolving the corrupted file (which is one click) allows the user to commit. I know that we can revert/reset to previous commits pretty easily but its kinda messy for the log history and we pretty much don't want to keep track of corrupted versions. Also it makes us lose much time since the "general user" will probably have diffulties reverting to previous version and might need help.

What I would like to do is first: When a user tries to merge files, Git doesn't modify compiled files from the working directory (working tree, etc.).

Second: I am pretty sure this is possible I just don't figure how, but I would like to automaticly generate the BASE, LOCAL and REMOTE files when selecting merge when a conflict occurs which would be more straight-forward then to have to manually select the Edit Conflict option. It occurs to me that .docx files allready do this but my .acd file doesn't. Is there an explanation?

As i said, I am fairly new and am widely opened to any ideas! :)

MrTux
  • 32,350
  • 30
  • 109
  • 146

1 Answers1

0

TortoiseGit does not modify a conflicted file by default, but Git does for text files.

Git does include conflict markers into text based files. If you don't want that to happen you could try to add a .gitattribtues file and declare your file as binary. binary is a shotcut for -diff -merge -text, so -merge could also be an option if the file is a text fileand you still want to see diffs.

You could also create a commit hook which checks for possible conflict markers in files before allowing to commit (cf. https://tortoisegit.org/docs/tortoisegit/tgit-dug-settings.html#tgit-dug-settings-hooks and prevent file with merge conflicts from getting committed in git).

MrTux
  • 32,350
  • 30
  • 109
  • 146
  • That makes total sense as when I try to open the file, it is text structured! But i guess Git's merge doesn't correspond exactly to what needs to be done. There's also that message written at begining of the file I'm trying to merge: This file was generated by the RSLogix 5000 software. DO NOT ALTER THIS FILE I will try it and let you know about the results since there isn't much informations about integrating Git with automation softwares of the Web. Thank you! – louloubaillargeon May 28 '20 at 11:41
  • Marking the file as `-merge` should do the trick. Git will still indicate a conflict, but does not alter the file, you could also use `merge=ours` for automatically resolving. – MrTux May 28 '20 at 13:28
  • Any news on this? @louloubaillargeon – MrTux Jun 04 '20 at 11:02
  • Hi MrTux. Not yet but I'm working on that project today and I will be trying this! – louloubaillargeon Jun 04 '20 at 14:25
  • Hi @MrTux! Marking the file as -merge in the gitattributes did the trick! No more corrupted files and the PLC merge tool opens instantly when we try to merge with Git. That made a lot of good for us. For people who wonder what exactly I did: 1: Create .gitattributes text file in repo 2: Add *.acd -merge 3: Git (Tortoise Git) still shows the file as conflicted but doesn't add any merging arrows. – louloubaillargeon Jun 08 '20 at 15:10