跨本地网络的 Git 克隆/拉取

Tom*_*rez 19 networking version-control git ubuntu-12.10

我正在尝试使用 Ubuntu Quantal 在另一台 PC 中克隆/拉取存储库。我之前在 Windows 上做过这个,但我不知道 ubuntu 上有什么问题。我试过这些:

git clone file:////pc-name/repo/repository.git
git clone file:////192.168.100.18/repo/repository.git
git clone file:////user:pass@pc-name/repo/repository.git
git clone smb://c-pc/repo/repository.git
git clone //192.168.100.18/repo/repository.git
Run Code Online (Sandbox Code Playgroud)

我总是得到:

Cloning into 'intranet'...
fatal: '//c-pc/repo/repository.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
Run Code Online (Sandbox Code Playgroud)

或者

fatal: repository '//192.168.100.18/repo/repository.git' does not exist
Run Code Online (Sandbox Code Playgroud)

更多的:

  • 另一台电脑有用户名和密码
  • 不是网络问题,我可以访问并ping通它。
  • 我刚刚安装了git做apt-get install git(安装了依赖项)
  • 我正在从终端运行 git(我没有使用 git-shell)

是什么导致了这个以及如何解决这个问题?任何帮助都会很棒!

更新

我已经在 Windows 上克隆了 repo,git clone //192.168.100.18/repo/intranet.git没有问题。所以,repo 是可访问的并且存在!也许问题是由于用户凭据?

89c*_*705 27

这取决于您如何配置服务器以提供内容。

如果通过 ssh:

git clone user@192.168.100.18:repo/repository.git
Run Code Online (Sandbox Code Playgroud)

或者如果网络服务器提供内容(http 或 https)

https://user@192.168.100.18/repo/repository.git
Run Code Online (Sandbox Code Playgroud)

或者如果通过文件路径可用:

git clone file://path/to/repo
Run Code Online (Sandbox Code Playgroud)

或者如果服务器正在运行 git 守护进程:

git clone git://192.168.100.18/repo
Run Code Online (Sandbox Code Playgroud)

  • 在 Windows 上,我使用 `git clone //192.168.100.18/repo/repository.git` 进行克隆,但我之前登录了 `192.168.100.18` 机器,所以这是 `file://` 方式吗? (3认同)
  • 有用的答案,谢谢!要克隆位于 Windows 共享文件夹中的存储库,我使用了 `git clone file://\\\PC1\path-to-repo-dir` (2认同)

小智 15

手册上git-clone说:

Git natively supports ssh, git, http, https, ftp, ftps, and rsync protocols
Run Code Online (Sandbox Code Playgroud)

请注意,SMB 不在列表中。

git在 Windows 上运行时,该//host/path语法有效,因为操作系统本身支持它 - SMB 远程路径可以用于任何可以使用本地路径的地方。在 unix 中情况并非如此,其中 SMB 是一个陌生的东西,//相当于/在路径名解析算法中。

挂载远程文件系统,然后您将能够使用git(以及系统上的所有其他工具)能够理解的 unix 样式路径名来引用它。

有关安装 smbfs 的信息:https ://askubuntu.com/questions/137011/how-to-mount-a-samba-shared-folder-ubuntu-x-ubuntu