Project file permissions and Git on Windows

What’s everyone doing for file permissions when using Git to back up projects?

I’m trying to set this up in a way that makes sense which seems to be difficult for Windows.

All of the project files are in “Program Files” 🤦 which isn’t user writable so I’m thinking my options are run git bash as admin which is obviously not ideal (and there’s no sudo on Windows) or add u+w to the projects folder which of course fails partway through. Is this a sane approach? Do I need to stop the gateway service to update file permissions? Who is supposed to own these files and does it even matter?

In typical Windows fashion I get errors like "An error occurred while applying security information to: " and then a partial filename because the operating system is too stupid to understand that wrapping text is a thing and that filenames may exist that are “more than 20 characters and less than the NTFS character limit + 1” in length

What’s the PowerShell equivalent to chown -R user ./projects; chmod -R u+w ./projects; sudo rm -rf / cause that’s about where I’m at :smiley:

I’ll invoke Cunningham’s law - I’m pretty sure git only stores the executable permission, not anything more complex. You can manually invoke an index update just in git, without actually modifying the files:
https://git-scm.com/docs/git-update-index#Documentation/git-update-index.txt---chmod-x; maybe that fits your needs? (which I’m not entirely clear on…)

Running git on Windows with services makes my head hurt. Y’all are masochists.

4 Likes

@chasondeshotel I am about where you are. Git is miserable in Program Files in Windows. Only semi-stable thing I have going is I run all my git commands as an Admin user, but agree its not pleasant.

Right now, we have Git invoking through the Project Update script, but we are soon looking to change that approach to a Git repo per project and have a Perspective UI that triggers sendMessage commands to the GW to execute git commits for projects when developers want to commit their project.

1 Like

Why do you want to change Unix file rights in Windows? I would not mess with file access within bash in Windows, as those rights are mostly ignored by Windows anyway. run git command directly without going through bash

If git have issue, it’s probably with writing to .git folder, which you can give access from within Windows once, and it should not change back

If you can give more details, or a sample script I can check, but Windows files when created usually inherit it’s parent rights, so changing projects folder manually will fix the issue, and you will only have to do this again when you setup a new gateway

1 Like

@PGriffith I actually saw that, good to know but not quite the issue I'm having. It's not any permsisions errors between copies of the repo, it's just the repo is not writable by users (as it inherits permissions from 'Program Files') so I have to run git commands as administrator (bad practice) or change the projects to user writeable (which may require stopping the gateway or have unintended side effects). I guess my question is "how are other people dealing with this?" and "how have others incorporated git into their workflow?"

Right now, we have Git invoking through the Project Update script, but we are soon looking to change that approach to a Git repo per project

That's an interesting approach. It seems like you'd lose a lot of the benefits of git... but that sounds super useful if you have developers you don't want to give ssh/rdp access to. I do repo per project; almost did git submodule but there's just too many ways someone could inadvertently overwrite your stuff

UI that triggers sendMessage commands to the GW to execute git commits

All this to get around permissions or...?

Why do you want to change Unix file rights in Windows?

I don't, I just want them to be user writable. Saying u+w was (poor given the context) shorthand

If git have issue, it’s probably with writing to .git folder, which you can give access from within Windows once, and it should not change back

That would work as long as you were only making changes locally and not pulling changes from anywhere else. As soon as git tries to change a file it's going to croak

Windows files when created usually inherit it’s parent rights, so changing projects folder manually will fix the issue

That was my first instinct but that update failed... presumably because Windows can't handle doing anything with open files :person_facepalming:. So I'm guessing I have to stop the gateway to update permissions and I figured I'd better ask around before taking the gateway down. And if I have to take the gateway down to update permissions every time I create a new project it sounds like running git as administrator is what I'll end up doing

Running git on Windows with services makes my head hurt

Yes exactly

1 Like

I know that I tried running all of the git commands from the gateway as os.system commands and they should have the right permissions (usually until someone tries to adjust something outside of ignition).

I do agree that Git on windows with ignition makes my head hurt quite a bit.

1 Like