Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git init failed with Permission denied #53

Open
dipucian opened this issue Aug 14, 2018 · 15 comments
Open

git init failed with Permission denied #53

dipucian opened this issue Aug 14, 2018 · 15 comments

Comments

@dipucian
Copy link

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
Copy link
Author

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

@pavelxkrejci
Copy link

  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?

@dipucian
Copy link
Author

dipucian commented Aug 14, 2018 via email

@pavelxkrejci
Copy link

pavelxkrejci commented Aug 14, 2018

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.

@EKoetsjarjan
Copy link

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

@EKoetsjarjan
Copy link

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 :)

@pavelxkrejci
Copy link

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

@holgerbrandl
Copy link

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

@snaphat
Copy link

snaphat commented Aug 9, 2019

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

@maiormarso
Copy link

maiormarso commented Jan 7, 2020

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

@Nabeel70
Copy link

Nabeel70 commented May 5, 2020

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

@smares
Copy link

smares commented Oct 20, 2020

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.

@peterbelm
Copy link

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.

@harri-pasanen
Copy link

Seems like the "git clone" would start working if sshfs was updated to v3.7.2, thanks to @peterbelm and libfuse/sshfs#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.

@ld0714
Copy link

ld0714 commented Oct 21, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests