sshfs-win icon indicating copy to clipboard operation
sshfs-win copied to clipboard

git init failed with Permission denied

Open dipucian opened this issue 6 years ago • 15 comments

I can map a network drive (Z:) and have read/write access to it, but when I try git init, it failed with error like: Z:/deployScript/.git/: Permission denied

image

where should I look? for these kind of problem.

Thanks

dipucian avatar Aug 14 '18 01:08 dipucian

I tried both \\sshfs\user@host and \\sshfs\windowsUser=user@host

dipucian avatar Aug 14 '18 01:08 dipucian

  1. If you run git from cygwin, try to start cygwin with elevated permissions as admin. Or try native windows build of git.
  2. Try to check permissions set for the user account on the ssh server. Does it work with different ssh client?

pavelxkrejci avatar Aug 14 '18 07:08 pavelxkrejci

I'm using native windows build, not running git from cygwin. And I have read write access to the folder with \sshfs, when I copy files into this folder on Windows, it appears to have the correct owner/group when I check on Linux side, so I think permissions for the Linux user is not a problem.

If I git init elsewhere and copy the .git folder into it, other git commands seems to work.

Chris

On Tue, Aug 14, 2018, 15:34 pavelxkrejci [email protected] wrote:

  1. If you run git from cygwin, try to start cygwin with elevated permissions as admin. Or try native windows build of git.
  2. Try to check permissions set for the user account on the ssh server. Does it work with different ssh client?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/billziss-gh/sshfs-win/issues/53#issuecomment-412781713, or mute the thread https://github.com/notifications/unsubscribe-auth/AAxxEgmDgSIgvkcgGxPWyPhLpSH1Ji0pks5uQn2PgaJpZM4V7ptT .

dipucian avatar Aug 14 '18 08:08 dipucian

The problem may be that windows git tries to set hidden attribute on ".git" folder which is not available on Linux/ssh. The error message would be than more likely result of git internal logic and not directly related to sshfs. Edit: This is confirmed in Process Monitor all git filesystem operations result with success.

pavelxkrejci avatar Aug 14 '18 14:08 pavelxkrejci

Hi @pavelxkrejci do you have any suggesition for a workaround? I have the same problem .

EKoetsjarjan avatar Feb 04 '19 10:02 EKoetsjarjan

I just maybe found one, I have logged in to the linux box and created a git repository using git init inside the shared folder . then I opened the shared folder from windows and tried to commit/fetch changes, all worked well :)

EKoetsjarjan avatar Feb 04 '19 11:02 EKoetsjarjan

Easiest might be just "git init" in a local folder and then move the ".git" folder to the intended ssh folder.

pavelxkrejci avatar Feb 04 '19 11:02 pavelxkrejci

This also is an issue when rendering reports with https://github.com/rstudio/rmarkdown which also created hidden directory (similar to the .git directory) and fails to run on directories mounted with sshfs-win

holgerbrandl avatar Jun 24 '19 14:06 holgerbrandl

Same problem with hg, but commits don't even work there.

snaphat avatar Aug 09 '19 00:08 snaphat

Win10, right click on the [Git Bash] icon and select 'Run as Administrator'

maiormarso avatar Jan 07 '20 04:01 maiormarso

Here is a simplest solution!! First show your hidden files of drives then open command-line By "Run as administrator"!!

Nabeel70 avatar May 05 '20 06:05 Nabeel70

I am using TortoiseHg and cannot do anything because of permission denied errors for the .hg directory.

Edit: Obviously referring to Mercurial and not Git.

smares avatar Oct 20 '20 09:10 smares

I've been tracking down this issue and it's a mixture of problems across three applications:

  • Git attempts to create the .git directory twice, the second time it calls wmkdir the call fails with permission denied - which Git reports and then exits. Attempting to create the directory twice isn't great, but I believe the subsequent handling of the error is correct.
  • According to this link a lot of SFTP servers (OpenSSH included) don't support the extended range of codes that could indicate that the directory exists, so it returns code 4 'Failure' - which isn't particularly helpful.
  • sshfs maps this status to the EPERM result code, hence why Git is getting permission denied. The correct result code for this situation should be EEXIST.

As you can see in the linked issue on sshfs I've submitted a patch that will check whether a directory is accessible if mkdir fails with EPERM, returning the correct EEXIST code if it is. With this patch I've been able to successfully clone a Git repo using sshfs-win.

peterbelm avatar Jan 16 '21 22:01 peterbelm

Seems like the "git clone" would start working if sshfs was updated to v3.7.2, thanks to @peterbelm and https://github.com/libfuse/sshfs/issues/243 being closed.

Now the workaround is to do the initial clone at host and then doing git config core.autocrlf false git config core.filemode false on windows in the mapped directory.

harri-pasanen avatar Aug 04 '22 13:08 harri-pasanen

I build the newest version and can solve it https://github.com/ld199607/sshfs-win

ld0714 avatar Oct 21 '22 04:10 ld0714