【发布时间】:2021-03-16 11:09:54
【问题描述】:
我有一个稍微复杂的问题,可以分为两个工作环境:
- 我的 Windows 10 工作电脑
- Linux 服务器,可通过 SSH、VNC 和使用 VPN 的联网 SAMBA 驱动器访问
服务器上有两个git repos:
- 存档的共享存储库,位于 //xxx.xxx.xxx.xxx/repos/git-matlab/
- 我的个人仓库,位于 //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