我在 Ubuntu 16.04 上,并与带有 GIT 存储库的 Windows 网络建立了 VPN 连接。我可以通过访问存储库
smb://192.168.1.71/users/Git/myrepo.git
但 GIT 不支持 smb 协议(protocol)。来自 git 手册
The following syntaxes may be used with them:
ssh://[user@]host.xz[:port]/path/to/repo.git/ git://host.xz[:port]/path/to/repo.git/ http[s]://host.xz[:port]/path/to/repo.git/ ftp[s]://host.xz[:port]/path/to/repo.git/ rsync://host.xz/path/to/repo.git/ [user@]host.xz:path/to/repo.git/
所以以下不起作用
git remote set-url origin smb://192.168.1.71/users/Git/myrepo.git
什么是好的解决方法?
最佳答案
通过挂载存储库
mkdir /mnt/windowsgit
sudo apt-get install cifs-utils
sudo mount -t cifs //192.168.1.71/users/Git /mnt/windowsgit -o user=USERNAME
在哪里
cifs-utils
需要挂载 smb 位置和 USERNAME
是 windows 网络所需的用户名。您将被要求输入密码。使用 myrepo.git 使用
git remote set-url origin file://mnt/windowsgit/myrepo.git
并使用
sudo git pull
sudo git push
自从
/mnt/
需要 sudo 权限。你可能会得到
fatal: '\192.168.1.71\Users\Git\myrepo.git' does not appear to be a git repository fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
在通常的 git 消息之后,我不知道为什么,但它仍然有效。
关于git - 如何从 Ubuntu16.04 连接到 Windows GIT 存储库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48137594/