简体   繁体   English

WSL2 环境中的 git 推送在写入对象步骤期间挂起

[英]git push in WSL2 environment hang up during Writing Objects step

Symptoms症状

I have a git workspace in WSL2 environment.我在 WSL2 环境中有一个 git 工作区。 The workspace is located under /mnt/c/workspace/repo where is also visible from Windows by the path C:\workspace\repo .工作区位于/mnt/c/workspace/repo下,从 Windows 通过路径C:\workspace\repo也可以看到。

When I do git push from WSL2 side in the workspace, Git hang up with this message.当我在工作区中从 WSL2 侧执行 git 推送时,Git 会挂断此消息。

Enumerating objects: 39, done.
Counting objects: 100% (39/39), done.
Delta compression using up to 16 threads
Compressing objects: 100% (24/24), done.
Writing objects:  34% (9/26)

This is the other observed behavior and environment information in this context.这是在此上下文中观察到的其他行为和环境信息。

  • I can push these files from Windows side with git for windows without any problems.我可以从 Windows 端与 git 一起推送这些文件,用于 windows 没有任何问题。
  • I can push several times just after cloning files.克隆文件后我可以推送几次。 It won't work after some of my push operations.在我的一些推送操作之后它不会工作。
  • This repository just contains text files.此存储库仅包含文本文件。 The entire repository size is less than 1MB整个存储库大小小于 1MB
  • I've used this environment for several months but I observed this issue just only for this repository我已经使用这个环境几个月了,但我只在这个存储库中观察到这个问题
  • This problem also happened when I copied entire folder to ~/workspace/repo where is not exposed to Windows directly.当我将整个文件夹复制到不直接暴露给 Windows 的 ~/workspace/repo 时,也会发生此问题。
  • The remote is configured to connect with SSH and use the key under /home/<username>/.ssh遥控器配置为连接 SSH 并使用 /home/<username>/.ssh 下的密钥

Environment information环境信息

  • Linux image in WSL: 20.04.2 LTS (Focal Fossa) WSL 中的 Linux 图像:20.04.2 LTS(Focal Fossa)
  • Git version: 2.25.1 Git 版本:2.25.1
  • Windows version: Microsoft Windows [Version 10.0.19042.844] Windows 版本:微软 Windows [版本 10.0.19042.844]
$ git config --global --list
user.email=<my mail address>
user.name=<my name>
http.postbuffer=524288000

Tried workarounds尝试过的解决方法

Configureing http.postBuffer配置 http.postBuffer

git config --global http.postBuffer 524288000

I've followed this answer in different question in stackoverflow.我在stackoverflow的不同问题中遵循了这个答案。 https://stackoverflow.com/a/26663047/3200358 https://stackoverflow.com/a/26663047/3200358

This workaround won't work for me.这种解决方法对我不起作用。

Windows permission change attrib -r +s Windows 权限变更属性 -r +s

I've followed this workaround to fix some permission problem in Windows side.我已经按照这个解决方法来修复 Windows 端的一些权限问题。 https://stackoverflow.com/a/63483040/3200358 https://stackoverflow.com/a/63483040/3200358

attrib -r +s C:\workspace\repo

This workaround won't work for me.这种解决方法对我不起作用。

Tried sudo git push试过 sudo git push

I've tried sudo git push for in case when git command can't access some lock files.我试过 sudo git push 以防 git 命令无法访问某些锁定文件。

sudo GIT_SSH_COMMAND='ssh -i /home/<username>/.ssh/id_rsa' git push origin master

This workaround won't work for me.这种解决方法对我不起作用。

Using https to push使用https推

The error message was changed.错误消息已更改。 But this workaround won't work for me.但是这种解决方法对我不起作用。

$ git push --set-upstream origin master -vvvv
Pushing to https://github.com/kyasbal-1994/<repo-name>.git
Enumerating objects: 39, done.
Counting objects: 100% (39/39), done.
Delta compression using up to 16 threads
Compressing objects: 100% (24/24), done.
Writing objects: 100% (26/26), 5.53 MiB | 7.42 MiB/s, done.
Total 26 (delta 6), reused 0 (delta 0)
POST git-receive-pack (5802813 bytes)
error: RPC failed; curl 92 HTTP/2 stream 0 was not closed cleanly: CANCEL (err 8)
fatal: the remote end hung up unexpectedly
fatal: the remote end hung up unexpectedly
Everything up-to-date

Have you tried invoking Windows' git from WSL by using the path to the Windows git.exe ?您是否尝试过使用 Windows git.exe git In fact you could set up an alias in your .bashrc :实际上,您可以在.bashrc中设置别名:

alias wgit='/mnt/c/path\ to\ git/Git/git.exe`

This way, you have a Windows executable dealing with Windows files instead of a Linux executable dealing with Windows files, though I'm a little fuzzy on how things work with the mounting. This way, you have a Windows executable dealing with Windows files instead of a Linux executable dealing with Windows files, though I'm a little fuzzy on how things work with the mounting.

However, I'm not sure how user-friendly this may be when entering paths.但是,我不确定输入路径时这可能对用户有多友好。

Assuming that works, there's probably even a way to write a smart wrapper function in bash that detects which file system the repo is on and invokes the right git executable...假设可行,甚至可能有一种方法可以在 bash 中编写智能包装器 function 来检测存储库所在的文件系统并调用正确的 ZBA9F11ECC3497D9993B933FDC2BD6...

As an alternative, you may have more luck maintaining 2 separate repos (WSL & Windows) and then syncing via push/pulls from a server.作为替代方案,您可能会更幸运地维护 2 个独立的存储库(WSL 和 Windows),然后通过服务器的推/拉同步。

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

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