So, I've created a git repository on the networked drive:
git init --bare --shared
and that works fine. Then, I clone it to a local drive with
git clone z:/testgit
and that also works fine. Then I add a file, stage, and commit
git stage *
git commit -m "test commit"
and that ALSO works fine. BUT! When I try to push to the origin, I get this error.
git push origin
Counting objects: 3, done.
Writing objects: 100% (3/3), 225 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: error: unable to write sha1 filename ./objects/f3/e6e90a7465421306fae05c18153260973542e3: Permission denied
remote: fatal: failed to write object
error: unpack failed: unpack-objects abnormal exit
To z:/testgit14
! [remote rejected] master -> master (unpacker error)
error: failed to push some refs to 'z:/testgit'
When attempting to use git stage * directly on the server (on a non --bare git project) I get similar errors.
I have full access to the drive in file explorer, and even able to initialize the repository with git. SSH shouldn't even apply here since it's not a server, it's a networked drive. Everything I've read about git says that this should work. I've read dozens of "how to's" that all say these exact steps, but no one complaining about permission denied, UNLESS they're talking about SSH public keys missing on servers (which, as I've said, shouldn't apply).
What permissions am I missing? Where should I look for and set the proper permissions?
Create a folder that will hold your git repository on your network share. I have a mapped drive on g: and my repository is g:\scripts so that is what my examples will use. From a cmd prompt change to your mapped drive. Then cd into your soon to be git repository. Then create an empty git repository.
I’ve been using git locally on my Windows machine at work to manage some scripts and I use a network drive as my remote in case my machine dies. Here are the steps I used to get that up and running. You will need to install git ( try msysgit windows installer) and learn about git ( try git immersion) before setting up your remote repository.
On the VM, under My Computer, the shared folder should appear, for example, as "Shared Folder on 'vmware-host' (Z:) Network Drive". On Git Bash on the VM, this should appear as /z/project-shared. Set up the repository Check out the repository on the host:
Can you turn a local network directory into a remote git repository? 1 1. Create remote repo. You can setup remote repo on your own server by git init --bare. And if the local machine can access to github, bitbucket etc. 2 2. Setup local repo if you have not setup. 3 3. Add remote repo as remote for the local repo.
What happens when you try to create the file that git
is complaining about?
echo test > ./objects/f3/e6e90a7465421306fae05c18153260973542e3
It's possible that git
is creating a new folder (f3
) and the folder is not getting the correct permissions, either due to ACL inheritance misconfiguration or because the local machine is trying to adjust the permissions on newly created folders and getting it wrong.
If it were Linux, it could be because the network drive was connected with the wrong mount options, or the umask was set incorrectly, but I'm not sure whether those are available to be changed on a Windows machine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With