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

Git Remote指向Windows Server的SSH URL正确格式咨询

解决Git通过SSH推送至远程Windows Server的路径格式问题

问题根源

你当前的Git Remote URL格式错误:远程Windows Server的路径不能直接写c:/Users/...,因为SSH会话中Git会按照类Unix的路径规则解析,c:/会被识别为相对路径而非Windows的盘符绝对路径,导致找不到仓库。

正确的SSH URL格式(两种可选)

格式1:大写盘符+无冒号+正斜杠路径

ssh://user@localhost:2202/C/Users/User/PSComputerManagementZp.git

格式2:盘符前加双斜杠(兼容部分Windows SSH环境)

ssh://user@localhost:2202//c/Users/User/PSComputerManagementZp.git

修复步骤

  1. 删除错误的远程配置
git remote remove win_test
  1. 添加正确的远程(二选一)
# 使用格式1
git remote add win_test ssh://user@localhost:2202/C/Users/User/PSComputerManagementZp.git

# 或者使用格式2
git remote add win_test ssh://user@localhost:2202//c/Users/User/PSComputerManagementZp.git
  1. 验证远程配置
git remote -v
  1. 测试推送(替换main为你的实际分支名)
git push win_test main

额外验证项

  • 确认远程Windows Server上的仓库是裸仓库,需在目标目录执行:
git init --bare PSComputerManagementZp.git
  • 确保SSH登录用户对该仓库目录有完整的读写权限

内容的提问来源于stack exchange,提问作者Little Train

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.15 06:32:42