You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu 16.04连接Windows Git仓库:SMB协议不支持的解决方法

Alright, let's tackle this issue since Git doesn't natively support SMB URLs—here are two solid solutions you can try right away:

Solution 1: Mount the SMB Share Locally (Quickest Fix)

This works by mapping the SMB network share to a local directory on your Ubuntu 16.04 system, so Git can treat the repository like a local folder.

  • First, install the SMB client utilities needed to mount the share:
    sudo apt-get update && sudo apt-get install cifs-utils
    
  • Create a local directory to mount the share into (pick any path you prefer):
    mkdir ~/windows-git-repos
    
  • Mount the SMB share. Replace your-windows-username and your-windows-password with your actual credentials for the Windows machine. If the Windows machine is part of a domain, add domain=your-domain-name to the -o options:
    sudo mount -t cifs //192.168.1.71/users/Git ~/windows-git-repos -o username=your-windows-username,password=your-windows-password
    
  • Now update your Git remote to use the local mounted path:
    git remote set-url origin ~/windows-git-repos/myrepo.git
    
  • You can now use standard Git commands (git pull, git push, etc.) as you would with any local or remote repository.

Optional: To make the mount persistent across reboots, add this line to your /etc/fstab file (replace placeholders with your details):

//192.168.1.71/users/Git /home/your-ubuntu-username/windows-git-repos cifs username=your-windows-username,password=your-windows-password,uid=$(id -u),gid=$(id -g) 0 0

The uid and gid parameters ensure the mounted files have your Ubuntu user's permissions, avoiding permission issues.

Solution 2: Set Up a Supported Git Protocol on the Windows Machine (More Scalable)

If mounting the share long-term isn't ideal, you can configure the Windows machine to serve the Git repository over a protocol Git supports (SSH, HTTP/HTTPS).

Option 2.1: Use SSH

Most modern Windows versions (10+) have a built-in OpenSSH server, or you can use the one included with Git for Windows:

  1. On the Windows machine, enable the OpenSSH Server (Settings > Apps > Optional features > Add a feature > OpenSSH Server > Install). Start the service and set it to auto-start via Services.msc.
  2. Ensure the Windows firewall allows incoming connections on port 22 (the default SSH port).
  3. On your Ubuntu system, update the Git remote to use the SSH path. Note that Windows paths are converted to Unix-style (e.g., C:\users\Git\myrepo.git becomes /c/users/Git/myrepo.git):
    git remote set-url origin your-windows-username@192.168.1.71:/c/users/Git/myrepo.git
    
  4. For convenience, set up SSH key authentication so you don't have to enter your password every time.

Option 2.2: Use HTTP/HTTPS

You can use tools like Gitblit, Gitea, or even IIS to host the repository over HTTP/HTTPS:

  1. Install a Git server tool on the Windows machine (Gitblit is lightweight and easy to set up).
  2. Add your myrepo.git repository to the server.
  3. Update your Git remote on Ubuntu to use the HTTP URL provided by the server, e.g.:
    git remote set-url origin http://192.168.1.71/git/myrepo.git
    
Quick Checks Before You Start
  • Verify your VPN connection is working: Ping 192.168.1.71 from Ubuntu to ensure you can reach the Windows machine.
  • If you run into permission issues with the SMB mount, double-check the Windows user has read/write access to the users/Git directory.

内容的提问来源于stack exchange,提问作者Leevi L

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 07:33:30