Using Git with Ignition projects

Hi - just wondering if anyone has had any experience using a version control system such as git, to keep track of Ignition projects. I’ve set up one of my projects as a repository, and it all works fine, but the problem is that Ignition always updates the resource.json file for each thing (view, named query, webdev script, etc), with last modified timestamps, as shown below, even when nothing has actually changed in that object:

  "actor": "external",
  "timestamp": "2022-05-31T05:07:05Z"
  "actor": "bakerjay",
  "timestamp": "2022-05-16T22:57:18Z"
"lastModificationSignature": "7f98dbe124869342123403fb8694e2ce989543b4f7cb8f8a0a5e3a10a2a95097"
"lastModificationSignature": "f8a5becab215e8c9c6e12f3570a2c335bc055292f7089dcc244739521ae20d02"

This means that I end up with dozens of ‘changed’ files each time I do a commit, and it obscures the actual changes I have made, and makes it easy to miss things. I can’t just exclude those files, because the project won’t work without them - and there are (very occasionally) actual important changes in those files I need to keep track of.

So - is there some way I can either a) tell GIT to ignore changes to those particular rows, or b), tell Ignition to stop updating those timestamps all the time? Or, I guess, c) Some other way entirely of managing version control.

Thanks very much

1 Like

Some information, and a not-that-great workaround in this thread:

1 Like

Thanks for the quick reply, I’ll give that a try

Ok, here’s my solution, which mostly seems to work pretty well.

Step 1: Create a powershell file called something like ps_fix_resource.ps1, containing:

filter sed($before,$after) { %{$_ -replace $before,$after} }
$input |sed '"actor": ".*"' '"actor": "system"'|sed '"timestamp": ".*"' '"timestamp": "2022-01-01T00:00:00Z"'|sed '"lastModificationSignature": ".*"' '"lastModificationSignature": "4a15e0122c9a955ca05b407bd9fa06810c1a05bd02f35e6ab4cc38c0654af46"'

This replaces your name (as ‘actor’) with system, the timestamp with a fixed time, and lastModificationSignature with a standard one. This way, all the files will end up looking the same, and won’t be picked up as changed by git. As far as I’ve seen so far, this doesn’t seem to upset Ignition too much.

Step 2: Add the following line to your .gitattributes file, which tells git to pass anything called resource.json through a filter before looking at it.
resource.json filter=resource_json_filter

Step 3: in your git config file for the repository ( /.git/config), add the following, which tells git what commands to actually run for that filter (clean and smudge are applied, respectively, on staging and on checkout. Weird names, but hey).

[filter "resource_json_filter"]
	clean = "powershell -File 'C:/script/ps_fix_resource.ps1'"
	smudge = "powershell -File 'C:/script/ps_fix_resource.ps1'"

And…that seems to be it! Still a few minor issues - the main one being that the powershell script seems to strip all the newlines from in the json file. It doesn’t seem to matter too much, but perhaps someone more well versed in powershell than I could post the fix for that. The other issue is that the .git/config seems to be specific to you, and to the repository (so each person would have to add this in to that file for every repository).

(Oh, I did have to open a command shell as administrator, and run: powershell Set-ExecutionPolicy RemoteSigned in order for the powershell script to actually run.)

You could do exactly the same thing on Linux using sed in a bash script.

Here’s some more info about clean and smudge: Git Smudge and Clean Filters: Making Changes So You Don't Have To - Big Nerd Ranch


This method avoids conflicts, but doesn’t it commit the resource.json files with a lastModificationSignature that doesn’t match the rest of the commit? Ignition will gracefully adjust that value on checkout, but that leaves uncommitted files sitting around.

It does, but as you say, Ignition adjusts that value so it doesn’t seem to matter - as far as I can tell there is no harm in never committing the changes to the lastModificationSignature, and the resource.json files no longer show in git as changed (or uncommitted ), which was what I was wanting

The other issue is that the .git/config seems to be specific to you, and to the repository (so each person would have to add this in to that file for every repository).

Each Person will have to use the same setup, true. However you can apply the settings systemwide, so that they are valid for each repo this person creates. This also gives you the possibility to share predefined settings with your team.

Configuration level Git command Storage location
Project configuration git config * [Repository]/.git/config
User configuration git config --global * [Userdir]/.gitconfig
system wide configuration git config --system * [Git install dir]/etc/gitconfig

The lowest configuration level which is configured will be applied. E.g. If you have the same setting in your system config and in the project config, the project config will be applied. So make sure not to override your system wide settings in the user or project config.

Sorry to bump this up again, but I've tried this, and for some reason it causes git add . to take an incredibly long time. it lists out CRLF warnings extremely slowly, does anyone know what might cause this? as well I've added the stuff that forces LF into the attributes file, so I'm not sure why those warnings even continue to show up

Hrmmm, not sure sorry. I've never had a speed issue like that, but a couple of my colleagues have - so not just you! We never managed to figure out why, though.

For reference, I'm using git version, Sourcetree 3.4.9, and pushing to github.