git - 如何从 Ubuntu16.04 连接到 Windows GIT 存储库?

标签 git ubuntu smb

我在 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/

    相关文章:

    sql-server - 在 Dockerfile 中切换到 Root 用户

    scala - 尝试在 IntelliJ IDEA 中运行工作表时获取 "Internal error: Scala instance doesn' t 存在或无效”

    Git 存储库从一台机器到另一台机器

    git - 没有什么可以比较的。没有什么可比较的,分支是完全不同的提交历史

    ubuntu - fatal error : Class 'Redis' not found

    Windows服务强化: Write-Restricted tokens & smb

    C - 如何将文件从 cifs 挂载到本地硬盘

    windows - 在 Win7 上映射和重新映射具有不同用户的网络驱动器

    git - 从特定分支 pull

    ruby-on-rails - Git + GitHub + Heroku