git init permission denied if no access to part of the path - windows

We've been trying to get git to work inside a windows server environment (version 2012 and 2016). It works mostly well, but our new user data storage moved to this CIFS-like shared drive (instead of local drives) and git init has permission trouble (trying this with git 2.29.2)
These are the steps to reproduce:
I have some code in this shared drive:
\\data-dist\DataVol_014\group\users\myusername\mycode\
So I navigate there with Windows file explorer and then right-click to call git bash here.
Git bash opens and then when I type git init, I get the following error:
fatal: Invalid path '//data-dist/DataVol_014/group': Permission denied
We certainly have read/write/modify access to the following levels of this path
\\data-dist\DataVol_014\group\users\myusername\mycode\
\\data-dist\DataVol_014\group\users\myusername\
\\data-dist\DataVol_014\group\users\
However, I CANNOT even view these levels:
\\data-dist\DataVol_014\group\
\\data-dist\DataVol_014\
And can ONLY view here:
\\data-dist\
Any clues how to get this to work?

Related

Git Gui on Windows: couldn't open ".git/PREPARE_COMMIT_MSG": permission denied

Been using Git Gui on Windows on a work computer for over two years now. Last night the repo was working fine, but this morning after a reboot, Git Gui pops up a message about "permission denied".
No idea what changed, although we did get an email saying that a corporate antivirus update had been pushed out which required a reboot. Also, a Windows update for December 2022 was installed on my machine which also required a reboot.
The full error message is:
couldn't open ".git/PREPARE_COMMIT_MSG": permission denied
couldn't open ".git/PREPARE_COMMIT_MSG": permission denied
while executing
"open [gitdir PREPARE_COMMIT_MSG] a"
(procedure "run_prepare_commit_msg_hook" line 8)
invoked from within
"run_prepare_commit_msg_hook"
(procedure "rescan" line 27)
invoked from within
"rescan ui_ready"
(procedure "do_rescan" line 2)
invoked from within
"do_rescan"
("after" script)
Things I have tried:
Based on suggestions in threads with similar "permission denied" errors, I ran the follow from a command prompt:
icacls "path\to\Work.git" /grant MyUserName:(OI)(CI)F /T
The command executed without errors, but no change to the repo.
Ran Git Bash (MINGW64) which runs without any immediate errors but only git status works. git add gives the error fatal: Unable to create '/path/to/Work/.git/index.lock': Permission denied
Tried a separate, personal, repo on the same work computer for a repo hosted on github.com. That worked fine (can commit, pull, etc.).
Any thoughts? My user account is part of the Administrators group, but it looks like the Windows and "corporate anti-virus" updates have modified or blocked something to do with my user account.
UPDATE 1
Rebooted Windows into Safe Mode. Now I can git add and git commit, though git push fails due to a failure to resolve dev.azure.com (something to do with the network not loaded in Safe Mode). Rebooted back into normal Windows and the problem returns: git add and other commands fail immediately and git push finds dev.azure.com but I get a permission denied error.
UPDATE 2
Based on the comments from #LeGEC, I checked the repo .git folder. There is no PREPRE_COMMIT_MESSAGE or index.lock file. The permissions haven't been touched by me, but after explicitly allowing my user "Full Control" over the folder, its still not working - still "permission denied" errors.
A colleague does not use Git for Windows, and was not having issues after the recent update. He suggested I try Visual Studio (which is tied directly into dev.azure.com)...and git works from Visual Studio 2019!
So we think that recent anti-virus or group policy changes has revoked, blocked or broken authentication of my user (presumably) connecting to the corporate network's and/or dev.azure.com. Somehow Visual Studio is able to authenticate me (through the Mcicrosoft Azure account?) which fails when using my Windows account....does that make sense?
Will update this question as and when I find out more details.
If anyone has seen this type of thing before (suddenly one application stops working with git with "permission denied" errors, while another works), your input would be appreciated!

Clone git repo hosted on a Windows shared folder from Mac OS X

I host a git remote repo on a Windows shared folder. I clone it using:
git clone //git-host-pc/SharedFolder/MyProject/
This command works from a Windows PC, but on a Mac, I get this error:
fatal: repository '//git-host-pc/SharedFolder/MyProject' does not exist
Trying git clone smb://git-host-pc/SharedFolder/MyProject gives me this error - fatal: Unable to find remote helper for 'smb'.
Note: I've found this question has been asked before mine - Use a git repos on a windows share from osx, however the OP there hasn't provided his exact commands, or the error messages, and that's why his question is unanswered.
Edit: I forgot to mention, but the shared folder is visible from the Mac, I can see it in Finder.
I kind of like to think that remote file system access is an OS thing, and that cloning repos is an application-level thing, so this would be my approach:
You should just be able to mount that SMB share with your OS'es functions to a local directory and clone from there, instead of hoping git has a transport for SMB.
How to mount:
Connect to the server on your Mac. Now, on your Mac, from Finder's Go menu, choose "Connect to Server." Enter the IP address you just obtained from your PC, preceded by smb://, as shown:
UPDATE: To use your PC's name instead of IP address, replace the number with the name. So if your PC's name is "MyWindowsBox", you'd use smb://mywindowsbox (not case-sensitive).
If it finds your server, you'll get prompted to enter your network credentials - by default, your Windows username and password:
Where to find the mounted folder:
Once I mounted the //git-host-pc/SharedFolder in that way, I found it in /Volumes/SharedFolder.
I've written this answer for those curious to know what git means by Unable to find remote helper for 'smb'
Git requires a helper program whenever it sees a URI such as ftp:// or smb://
When git encounters a URL of the form <transport>://<address>, where
<transport> is a protocol that it cannot handle natively, it
automatically invokes git remote-<transport> with the full URL as the
second argument
Source: https://git-scm.com/docs/git-remote-helpers
Basically you do not have git remote-smb installed. You can use git help -a to see what helpers you have installed.
Until somebody writes a git remote-smb helper, it's probably best to just mount the drive you want as mentioned in another answer.

Using SSH Keys on different Mac

I have GIT and my repos setup on a MacBook Air. I'm trying to clone the repo on my iMac. My understanding was that I needed to copy my key over from the /.ssh folder on the MBA to the same folder iMac.
However, when I try and clone the repo on the iMac, I get the following error:
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I've done a little research already and have verified that...
I have the latest version of GIT and that my user.name and user.email variables are configured correctly. (New Mac - new SSH keys for github?)
the ownership & permissions on the .gitconfig file and parent folder are r/w and owned by my user. (Trouble setting up Tower with my GitHub Account - error: could not lock config file)
my $HOME environment variable points to my users working directory. (Trouble setting up git with my GitHub Account error: could not lock config file)
At this point, I am all out of ideas and could really use some advice.
Suggestions?
Thanks!
Can't believe I found the solution right after I got done posting this, but for those who are copying keys to new machines, you have to let SSH know the keys are there. See this answer for details:
https://stackoverflow.com/a/12100237/337824

Jenkins configuration of git plugin

I get this error when configuring git repo in a new jenkins project:
Failed to connect to repository : Error performing command: ls-remote -h file:///c:\Dev\git\rx HEAD
I have a local git repo on my windows machine and cloning the same path from command prompt works on the same machine. I don't know what could be the problem (git.exe is on system path)
Windows installs Jenkins as a service. But it runs the Jenkins service under different user permissions that don't have access to GIT. You can follow this link to find the user that Jenkins runs under. http://antagonisticpleiotropy.blogspot.com/2012/08/running-jenkins-in-windows-with-regular.html
For example. My local user name on my windows is "nathandrewsire", exclude the quotes. Open windows services manager (either cmd and c:\services.msc, OR use windows key + R). Enable Log On > This account:. Then type in .\username (e.g. .\nathandrewsire). Then restart the service and you will have access to GIT from Jenkins builds.
I also found a snippet for windows shell command that will output the user to verify it.
echo %PATH%
echo %USERDOMAIN%\%USERNAME%
http://antagonisticpleiotropy.blogspot.com/2012/08/running-jenkins-in-windows-with-regular.html
Linux
If you're using Linux, this error can also be caused from not enabling share on your Git repo. Linux jenkins user won't be able to access Git report under another user unless....
git --bare init --shared=group
Also, your jenkins user and Git repo user must belong to the same group for file permission access. There's other alternatives to that like messing with umasks and ACL's but setting up a linux group for your two users is the easiest way.
Make sure NOT TO OVERWRITE your Git repo with the bare init command. If you already have a Git repo, you'll need to setup/move to a new one with the shared option. I didn't see a way to convert existing repos to shared because I am guessing the files would all need to be updated?
NOTE***
I used VMWare Workstation shared folders to build on a windows guest. Jenkins needs the following format when entering the Git repo.
//vmware-host/Shared Folders/vm-share/ridcyDevelopment.git/
Unable to get Jenkins and Git to play nice

Setting up a Git repository under Review-Board on Windows Server 2003

I need some help.
I have a Windows Server 2003 computer that I'm setting up with Git and Review-Board.
My Git repositories are managed by Gitolite. The setup is successful and everything is working fine (tested with multiple workstations).
The Review-Board site has installed successfully and is hosted under Apache 2.2. This is also working fine in itself (the website is accessible and responds for workstations), except the part where I'm trying to link Git repositories to Review-Board.
Most tutorials (example: http://ericholscher.com/blog/2011/jan/24/using-reviewboard-git/) provide good details on how to setup a Git repository under Review-Board, except that they refer to Linux/Unix systems, and I am running Windows Server 2003.
My Gitolite repositories are stored under D:\Repositories\Git
Example: D:\Repositories\Git\sdu-test\.git
My understanding is that Review-Board needs a local clone of the repository(ies). Therefore, I created a directory named LocalClones and I cloned my repository.
Example: D:\Repositories\LocalClones\[I cloned sdu-test.git here]
Command used (from LocalClones directory): git clone ../Git/sdu-test.git(the clone was successful)
Now, in Review-Board, I'm trying to declare my sdu-test repository.
Name is 'sdu-test'
Hosting type is 'Custom'
Repository type is 'Git'
Path is 'D:\Repository\LocalClones\sdu-test' (I have also tried with 'sdu-test.git', and 'sdu-test/.git')
Mirror path is 'ssh://git#localhost/sdu-test' (I have also tried simply 'git#localhost:sdu-test', and no mirror path at all)
When I click Save, I get the following error: (11001, 'getaddrinfo failed'). I have no idea what to do about that.
If I try to change the path to a Unix-style path ('/D/Repository/LocalClones/sdu-test'), I get a different error message: Permission denied accessing the local Git repository '/D/Repository/LocalClones/sdu-test'. With a Unix-style path, I could even write a directory path that doesn't exist ('/I/Dont/Exist') and the same permission denied error is returned (the path in the error message does reflect the change though).
Can anyone help me out and tell me how to declare my local Git repository in Review-Board under Windows?
Thank you very much!
** UPDATE ** thank you Tamagochi and VonC for your answers, but unfortunately they're not working for me. Even after fixing the git.py file, I still get the Permission denied accessing the local Git repository '/D/Repository/LocalClones/sdu-test' error message.
There appears to be a bug in ReviewBoard 1.5.5 that causes this error. You can resolve this problem in either of two ways:
Move your repositories to drive C.
Edit \reviewboard\scmtools\git.py file, and replace the following line:
self.git_dir = url_parts[2]
with:
self.git_dir = url_parts[1] + url_parts[2]
Then use the following path: file://D:/Repository/LocalClones/sdu-test
I don't have any experience with ReviewBoard, but from what I can gather (from your link):
you do need to put the full path up to the .git directory of the local clone.
you should make your local clone through an url-based address. If the local file protocol is to be used, you should try with file///D/Repository/LocalClones/sdu-test.
git#localhost:sdu-test would only work if you have a git daemon running.
ssh://git#localhost/sdu-test would only work if you have a ssh daemon running.

Resources