git unable to index files outside of repo (Permission Denied)

64 Views Asked by At

I have been working on setting up a windows task to automatically push all items from a shared network drive folder into an online repository with a domain user account (more info here). I have set up my local git repo outside of this shared network drive folder to prevent other users from running git commands or messing up the repo settings. When my automated task goes to add in the files from outside the repo, I am met with this error:

error: open("Path/to/file/I/want/to/add.txt"): Permission denied
error: unable to index file 'Path/to/file/I/want/to/add.txt'
fatal: adding files failed

Here is my task configuration:

General tab

  • user account is set to "domainUser"
  • "Run whether user is logged on or not" is selected
  • "Run with highest privileges" checked

Actions tab

  • Action set to "start a program"

in the properties of this action:

  • program/script is set to C:\Window\System32\cmd.exe
  • Add arguments set to /D /C D:\repo\commit.bat
  • Start in set to D:\repo

Conditions tab

  • Default checks in place
  • Wake the computer to run this task is checked

Here is the bat file that is ran by the task scheduler to upload the files from the network drive folder:

git config --global user.name "domainUser"
git config --global user.email "[email protected]"
git config --system --add safe.directory D:/repo
set HOMEDRIVE=C:
set HOMEPATH=\Users\domainUser
cd /D D:\repo
D:\path\to\git.exe --git-dir=C:\repo\.git add --all > log.txt 2>&1
D:\path\to\git.exe --work-tree^=//path/to/network/drive/folder add --all > log.txt 2>&1
D:\path\to\git.exe --git-dir=C:\repo\.git -c user.name="domainUser" -c user.email="[email protected]" commit --author="domainUser<[email protected]>" -m "message" >> log.txt 2>&1
echo Pushing changes... >> log.txt 2>&1
set GIT_TRACE=true
D:\path\to\git.exe --git-dir=C:\repo\.git push origin main >> log.txt 2>&1

the domainUser also uploads files from the local repo such as the README.md and does not have a "pemission denied" issue with these files. It's only the external files.

please keep in mind that this information has been masked for security reasons.

1

There are 1 best solutions below

0
bocodes On BEST ANSWER

The permission issue was resolved by

  • navigating to the network drive
  • opening the folder I needed permission to
  • open the folders properties window
  • open the security tab
  • add my domain user to the Group or user names section
  • give my domain user the following permissions: Modify, Read & execute, List folder contents, and Read.

thank you everyone for taking time to help figure this out.