Git over samba - 无法写入 sha1 文件名 | 没有权限

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3829498/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 04:37:00  来源:igfitidea点击:

Git over samba - unable to write sha1 filename | Permission denied

gitubuntusambapermission-denied

提问by InfoTracer

When I am using git over samba share on windows I get an error when i want to commit a file via git_extentions or tortoiseGIT. The error is: error: unable to write sha1 filename .git/objects/b4/e819f886bf31b67c42249a0eff8e8b16cf7622: Permission denied. When I add the file via the ubuntu server and commit the file it works fine. I am also working in a banrch.

当我在 Windows 上通过 samba 共享使用 git 时,当我想通过 git_extentions 或 tortoiseGIT 提交文件时出现错误。错误是: 错误:无法写入 sha1 文件名 .git/objects/b4/e819f886bf31b67c42249a0eff8e8b16cf7622: Permission denied。当我通过 ubuntu 服务器添加文件并提交文件时,它工作正常。我也在一个banrch工作。

I have already tryed chmod 777 the whole .git folder.

我已经试过了chmod 777 the whole .git folder

回答by john

I've seen this, too. It's a git defect, likely to do with how it creates and modifies files. To clarify the problem:

我也见过这个。这是一个 git 缺陷,可能与它如何创建和修改文件有关。澄清问题:

# mount a samba share locally. 
$ mount -t cifs options //share/project  /mnt/project

# The share contains a git checkout.
# Do some typical development.
$ cd /mnt/project
$ vi file    ## ok
$ git pull   ## ok
$ git status ## ok
$ git add file ## error!
  error: unable to create temporary sha1 filename 
  .git/objects/8b/tmp_obj_mYE1Xi: Permission denied


## But everything from the shell seems to work.
$ ls -latr .git/objects/8b/  ## ok. empty dir.
$ touch .git/objects/8b/tmp_obj_mYE1Xi ## ok.
$ echo test123> .git/objects/8b/tmp_obj_mYE1Xi ## ok.
$ cat  .git/objects/8b/tmp_obj_mYE1Xi  ## ok.
test123
$ rm  .git/objects/8b/tmp_obj_mYE1Xi  ## ok.

In git version 1.5.6.5 (latest Debian package), you get the error when you try to git-add. If you install git 1.7.3.2 (latest release), you can add the file, but you will get the error when you attempt to commit.

在 git 版本 1.5.6.5(最新的 Debian 软件包)中,当您尝试git-add. 如果您安装 git 1.7.3.2(最新版本),则可以添加该文件,但尝试提交时会出现错误。

回答by dkinzer

This issue has been seen before in some form or another for Git/Samba installations. Not sure if the source of the problem has been pin pointed yet:

这个问题以前在 Git/Samba 安装中以某种形式出现过。不确定问题的根源是否已经被指出:

http://code.google.com/p/msysgit/issues/detail?id=130#makechanges

http://code.google.com/p/msysgit/issues/detail?id=130#makechanges

Update:

更新:

looks like git v. 1.7.3.3 has resolved this issue.

看起来 git v. 1.7.3.3 已经解决了这个问题。

回答by Ian Vaughan

Ok, I have found a solution that worked for me.

好的,我找到了一个对我有用的解决方案。

I have been using git over samba (samba-common-3.0.33-3.7.el5)for ages with no problems.

我多年来一直在 samba (samba-common-3.0.33-3.7.el5) 上使用 git ,没有任何问题。

I upgraded git to Git-1.7.6-preview20110708, and it all went to pot!

我将 git 升级到Git-1.7.6-preview20110708,一切顺利!

As Im such a methodical developer, I didnt write down what I upgraded from!

作为我这样一个有条不紊的开发人员,我没有写下我升级的内容!

So I went through the list of previous releases and saw a Star next to Git-1.7.0.2-preview20100309, so a bit old, but put that on.... and bang... it works!

所以我浏览了以前版本的列表,在Git-1.7.0.2-preview20100309旁边看到了一个 Star ,所以有点旧,但是把它放在......然后砰......它起作用了!

回答by Eric

we started to use git today. version 1.7.10 was fine for win7 machines. on winXP we occurred the given error. for those machines we downgraded to 1.7.0.2 as Ian stated in his post and it works now.

我们今天开始使用git。1.7.10 版适用于 win7 机器。在 winXP 上,我们发生了给定的错误。对于那些机器,我们降级到 1.7.0.2,正如 Ian 在他的帖子中所说,现在可以使用了。

回答by Onshop

In my case it was the anti-virus software on Windows locking the file(s). Temporarily disabling the anti-virus fixed the problem.

就我而言,它是 Windows 上的防病毒软件锁定文件。暂时禁用防病毒解决了这个问题。

回答by lsu_guy

I answered this question over hereas well

我在回答了这个问题在这里

In my case, it looks like Git (v 2.6.3) tried to create its own read/write permissions on the Samba drive. This would prevent the pack files and/or objects from getting written (unpack error)

就我而言,看起来 Git (v 2.6.3) 试图在 Samba 驱动器上创建自己的读/写权限。这将防止打包文件和/或对象被写入(解包错误)

remote: error: unable to write sha1 filename ./objects/pack/pack-<some_hex_string>.pack: Permission denied
remote: fatal: cannot store pack file
error: unpack failed: index-pack abnormal exit
To z:\git\<repo name>
 ! [remote rejected] master -> master (unpacker error)
error: failed to push some refs

I went back and forth on trying to fix. Finally, since I had control of the Samba machine, I added a line to the samba drive config, which says "inherit permissions = yes". I restarted Samba and tried to push. It worked!

我来回试图修复。最后,因为我可以控制 Samba 机器,所以我在 samba 驱动器配置中添加了一行,上面写着“继承权限 = 是”。我重新启动了 Samba 并尝试推送。有效!

This worked for me since I'm the only person using the Samba server. For others, you may have the play around with "force directory mode" or "force create mode". You can find the man pages for those over here:

这对我有用,因为我是唯一使用 Samba 服务器的人。对于其他人,您可能会尝试使用“强制目录模式”或“强制创建模式”。你可以在这里找到这些人的手册页:

https://www.samba.org/samba/docs/man/Samba-HOWTO-Collection/AccessControls.html

https://www.samba.org/samba/docs/man/Samba-HOWTO-Collection/AccessControls.html

回答by Reactormonk

Probably samba blocks dotfiles? Why not use ssh instead of samba for pushing?

samba 可能会阻止 dotfiles?为什么不使用 ssh 而不是 samba 进行推送?