简体   繁体   English

Git 在 Ubuntu 上使用 Samba:“取消文件链接”

[英]Git with Samba on Ubuntu: “Unlink of file”

My configuration:我的配置:

  • remote repository on Gitlab. Gitlab 上的远程存储库。

  • Windows 10 machine with git (v. 2.25.1.windows.1) Windows 10 机器与 git (v. 2.25.1.windows.1)

  • Linux machine (Ubuntu) for local repositories (S:) with Samba (v. 4.11.6-Ubuntu) Linux 机器 (Ubuntu) 用于本地存储库 (S:) 与 Samba (v. 4.11.6-Ubuntu)

The problem问题

From the Windows 10 machine CLI:从 Windows 10 机器 CLI:

git clone -v --recurse-submodules --progress --verbose "https://gitlab.com/my-org/my-project.git" "S:/workspace/my-project/code"

I'm getting this error:我收到此错误:

POST git-upload-pack (175 bytes)
remote: Enumerating objects: 1591, done.
remote: Counting objects: 100% (1591/1591), done.
remote: Compressing objects: 100% (1259/1259), done.
remote: Total 1591 (delta 318), reused 1543 (delta 270), pack-reused 0
Receiving objects: 100% (1591/1591), 6.60 MiB | 5.46 MiB/s, done.
Resolving deltas: 100% (318/318), done.

Unlink of file 'assets/main/packs/fancybox' failed. Should I try again? (y/n)

Troubleshooting故障排除

The problem is not always related to the same directory (in this example: "fancybox").问题并不总是与同一个目录有关(在本例中:“fancybox”)。 But it always occurs after the download is complete (100%)但它总是在下载完成后发生(100%)

From my Windows machine, with ProcessExplorer, I don't see any process blocking that folder.在我的 Windows 机器上,使用 ProcessExplorer,我没有看到任何进程阻止该文件夹。 Likewise, the same from the Linux machine with Samba.同样,Linux 机器与 Samba 相同。

This is my smbstatus -L:这是我的 smbstatus -L:

28971  65534  DENY_NONE  0x120089    RDONLY  LEASE(RWH)  /home/htdocs   workspace/my-project/code/.git/objects/pack/pack-3f0aa70acd802c42ee978f95bc62f61f24dc07d6.idx
28971  65534  DENY_NONE  0x12019f    RDWR    LEASE(RWH)  /home/htdocs   workspace/my-project/code/.git/index.lock
28971  65534  DENY_NONE  0x120089    RDONLY  LEASE(RWH)  /home/htdocs   workspace/my-project/code/.git/objects/pack/pack-3f0aa70acd802c42ee978f95bc62f61f24dc07d6.pack

On:上:

Unlink of file 'assets/main/packs/fancybox' failed. Should I try again? (y/n)

I tried to unlock this locked folder:我试图解锁这个锁定的文件夹:

  • to assign permissions 777 to all respository为所有存储库分配权限 777
  • to kill the Samba process 28971 about my folder杀死关于我的文件夹的 Samba 进程 28971

but git keeps asking me if i want to try again:-(但是 git 一直问我是否要再试一次:-(

I also tried setting up to have multiple debug messages:我还尝试设置有多个调试消息:

GIT_CURL_VERBOSE = 2

but I didn't get the info I need.但我没有得到我需要的信息。

This problem occurs to me and to another user.这个问题发生在我和另一个用户身上。 While to another colleague (same configuration), never.而对另一个同事(相同的配置),从来没有。

In my office, for everything else, the network works well: we have no problems for copying, moving files from Win to Linux machine on the network.在我的办公室,对于其他一切,网络运行良好:我们在网络上将文件从 Win 复制、移动到 Linux 机器上没有问题。

Some idea?有什么想法?

A bit late, but I encountered this issue too and after some transversal research, I found out what is (at least one of) the cause of such weird behavior.有点晚了,但我也遇到了这个问题,经过一些横向研究,我发现了这种奇怪行为的(至少一个)原因。

SMB has a cache whose default settings are too much aggressive for GIT, which during checkout or clones needs to create a lot of consecutive files. SMB 有一个缓存,其默认设置对于 GIT 过于激进,在结帐或克隆期间需要创建大量连续文件。 Please see below link:请看下面的链接:

https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-7/ff686200(v=ws.10)#details https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-7/ff686200(v=ws.10)#details

Although this article refers to older versions of Windows, everything is still valid for latest Windows 10 Builds.尽管本文指的是旧版本的 Windows,但对于最新的 Windows 10 版本,一切仍然有效。

So, at the expense of some traffic increase between the local machine and the one where the samba share resides, GIT can work in a solid and stable way.因此,以本地机器和 samba 共享所在机器之间的一些流量增加为代价,GIT 可以稳定地工作。

You can disable such cache by directly creating a registry key:您可以通过直接创建注册表项来禁用此类缓存:

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Lanmanworkstation\Parameters
[DWORD] FileInfoCacheLifetime = 0
[DWORD] DirectoryCacheLifetime = 0

Or by using Powershell Admin或使用 Powershell 管理员

Set-SmbClientConfiguration -DirectoryCacheLifetime 0
Set-SmbClientConfiguration -FileInfoCacheLifetime 0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM