【问题标题】:Git clone/pull issues from serverGit 从服务器克隆/拉取问题
【发布时间】:2021-03-16 11:09:54
【问题描述】:

我有一个稍微复杂的问题,可以分为两个工作环境:

  1. 我的 Windows 10 工作电脑
  2. Linux 服务器,可通过 SSH、VNC 和使用 VPN 的联网 SAMBA 驱动器访问

服务器上有两个git repos:

  1. 存档的共享存储库,位于 //xxx.xxx.xxx.xxx/repos/git-matlab/
  2. 我的个人仓库,位于 //xxx.xxx.xxx.xxx/my-username/repos/personal-repo/

我已经在两个系统上设置了我的 SSH 密钥(它们存在于 ~/.ssh 中)。

我已经能够从我的 Windows 机器推送、拉取和克隆到个人仓库,没有任何问题。

尝试从我的 Windows 机器克隆到 git-matlab 时,我收到以下错误:

$ git clone --branch=main //xxx.xxx.xxx.xxx/repos/git-matlab/
Cloning into 'git-matlab'...
error: refs/heads/main does not point to a valid object!
fatal: Remote branch main not found in upstream origin

尝试使用 PuTTY 从服务器上的个人 Linux 环境克隆到 git-matlab 时,我收到一个大错误。输出总结如下:

$ git clone --branch=main /home/repos/git-matlab/

...

warning: failed to stat /home/repos/git-matlab/.git/objects/a5/1396ecd11cf0fd93cedd0dff1deda885508e3d

warning: failed to stat /home/repos/git-matlab/.git/objects/a5/f60d21cf9955ab0b6c82c12fefaa9e1f51dfc0

warning: failed to stat /home/repos/git-matlab/.git/objects/f3/.

warning: failed to stat /home/repos/git-matlab/.git/objects/f3/..

warning: failed to stat /home/repos/git-matlab/.git/objects/f3/4fd030aeee62a14e915e1fe06d2a7a22e2595e

warning: failed to stat /home/repos/git-matlab/.git/objects/f9/.

warning: failed to stat /home/repos/git-matlab/.git/objects/f9/..

warning: failed to stat /home/repos/git-matlab/.git/objects/f9/7e571b07827b8e32be70c38191cae18e3295b9

done.

一个带有 .git 目录的 git-matlab 文件夹会被输出,但仅此而已。

我应该补充一点,这些都是共享存储库。我也有权通过 Windows 资源管理器和 Nautilus(Linux 文件资源管理器)查看 git-matlab 目录。

任何帮助或见解将不胜感激。提前致谢。

【问题讨论】:

  • 你的 Git repo //xxx.xxx.xxx.xxx/repos/git-matlab/ 似乎是一个 SAMBA 共享。在这种情况下,SSH 密钥与使用 Git 无关。我不知道 Git 是否可以在此设置中正确处理对共享存储库的并发访问。当在 Linux 上运行的 Git 客户端和在 Windows 上运行的 Git 客户端访问同一个存储库时,您也可能会遇到问题。我建议设置一个适当的具有 SSH 访问权限的 Git 服务器。请edit您的问题并显示//xxx.xxx.xxx.xxx/repos/git-matlab//home/repos/git-matlab/.git/的非递归目录列表显示您在Linux上使用的确切命令。
  • 它是一个 SAMBA 驱动器,是的。如果它在同一台服务器上,我能够从我的 Windows 机器克隆到“个人仓库”并与之交互,这很奇怪。感谢您的其他 cmets - 我一定会记住这些。我按要求进行了编辑。
  • 警告warning: failed to stat /home/repos/git-matlab/.git/objects/... 可能是由于另一个进程同时修改了存储库。我不知道 Git 在使用共享文件夹时是否可以处理这个问题。这可能取决于用于共享数据的网络协议。再说一句:对于共享存储库,您应该使用裸存储库,该存储库通常在 /home/repos/git-matlab.git/ 而不是 /home/repos/git-matlab/.git/ 中包含 Git 的内部文件。

标签: linux windows git ssh server


【解决方案1】:

首先,请确保使用 latest Git For Windows,考虑到 2019 年第四季度的 support for UNC path was improved

其次,如果服务器可以通过 SSH 访问,那么试试那个协议

git clone ssh://remoteUSer@xxx.xxx.xxx.xxx/full/path/to/repo

【讨论】:

  • 感谢您的回答。可悲的是,在使用我的密码进行身份验证后,我得到了完全相同的错误
猜你喜欢
  • 1970-01-01
  • 2011-03-08
  • 2013-10-03
  • 1970-01-01
  • 2016-01-03
  • 2018-05-13
  • 1970-01-01
  • 1970-01-01
  • 2023-04-10
相关资源
最近更新 更多