New to PowerShell Universal. Having an issue with Git sync?

Product: PowerShell Universal
Version: 2.12.4

Hi there everyone,

So at the moment, we have recently installed PowerShell Universal, configured the SSL cert and got it up and running within our Okta environment. Well the next thing I wanted to do was to get it synced up with a new Git Repo (remote). So, I have done the following:

  • Created a new remote Repo in our Enterprise Git (powershell.universal)
  • Created a new PAT
  • Edited the appsettings.json GitRemote, GitBranch, GitUsername (my github email for login), GitPassword (PAT), GitBranch (master), and GitSyncBehavior (TwoWay).

I had deleted all of the contents within the C:\ProgramData\UniversalAutomation\Repository directory including the .universal directory. Before I did that I copied that directory to my remote Repo. I then saved the appsettings.json and restarted the PowerShell Universal service. It restarted just fine and when I logged in and went to the Git section I see the remote repo listed as well as master branch. I also see that it successfully cloned the repo and my roles.ps1 and environments.ps1 configuration scripts are there.

However, the issue I am now running into is that if I make any changes to say, the roles.ps1 script within the PowerShell Universal web console, it does NOT sync with my remote?

Likewise, if I say, on my laptop where I have cloned the remote repo, make a change to the roles.ps1 file and upload that to the remote repo (git push) that does not kick in an update on the PS Universal server?

In the logs I am seeing this:

2022-08-25 11:09:05.569 -04:00 [ERR] Failed to sync: 1 conflict prevents checkout at LibGit2Sharp.Core.Ensure.HandleError(Int32 result) in //LibGit2Sharp/Core/Ensure.cs:line 154
at LibGit2Sharp.Core.Proxy.git_checkout_tree(RepositoryHandle repo, ObjectId treeId, GitCheckoutOpts& opts) in /
/LibGit2Sharp/Core/Proxy.cs:line 229
at LibGit2Sharp.Repository.CheckoutTree(Tree tree, IList`1 paths, IConvertableToGitCheckoutOpts opts) in //LibGit2Sharp/Repository.cs:line 956
at LibGit2Sharp.Repository.FastForwardMerge(AnnotatedCommitHandle annotatedCommit, MergeOptions options) in /
/LibGit2Sharp/Repository.cs:line 1596
at LibGit2Sharp.Repository.Merge(AnnotatedCommitHandle annotatedCommits, Signature merger, MergeOptions options) in //LibGit2Sharp/Repository.cs:line 1470
at LibGit2Sharp.Repository.MergeFetchedRefs(Signature merger, MergeOptions options) in /
/LibGit2Sharp/Repository.cs:line 1254
at LibGit2Sharp.Commands.Pull(Repository repository, Signature merger, PullOptions options) in /_/LibGit2Sharp/Commands/Pull.cs:line 38
at UniversalAutomation.Git.GitService.Pull() in C:\actions-runner_work\universal\universal\src\Universal.Server\Services\GitService.cs:line 327
at UniversalAutomation.GitSyncService.TrySync() in C:\actions-runner_work\universal\universal\src\Universal.Server\Services\GitSyncService.cs:line 152
at UniversalAutomation.GitSyncService.Sync() in C:\actions-runner_work\universal\universal\src\Universal.Server\Services\GitSyncService.cs:line 77

Update:

I went ahead and cleared the local contents once again of the C:\ProgramData\UniversalAutomation\Repository directory. Within a minute it populated again with what is in our Git remote Repo, yay!

I then went ahead on my laptop, where I cloned the remote repo and opened the roles.ps1 file and added in a simple comment. I saved, committed and pushed the changes to our remote Repo. Within a minute, I RDP’d into our PowerShell Universal server and it looks like the changes took! I see the updated roles.ps1 locally in the C:\ProgramData\UniversalAutomation\Repository directory.

Refreshing our PowerShell Universal web console also shows the changes to the roles.ps1 file located in Settings > Configurations > roles.ps1

So, I guess I am good to go? But for some reason it doesn’t seem like changes made in the console get uploaded to the git remote? Is that normal behavior? Not sure if this matters but for sake of listing everything, we also have the PowerShell Universal service running as one of our Active Directory service accounts, although I wouldnt think that would affect changes made to the local PSU environment from syncing back with our remote Git Repo?