【问题标题】:git push to gerrit server doesn't work when setting git remote set-url --push, but works if I type in the URL manually设置 git remote set-url --push 时 git push 到 gerrit 服务器不起作用,但如果我手动输入 URL 则有效
【发布时间】:2014-03-27 00:52:34
【问题描述】:

我无法将我的代码从 git 推送到 gerrit。首先我检查了这样的代码:

git clone ssh://user@location.com:22/path/to/code

然后我尝试像这样设置一个推送网址:

git remote set-url --push origin "someotherlocation.com:/path/to/code HEAD:refs/for/master"

当我执行git push 时,它会返回此错误:

fatal: '/path/to/code HEAD:refs/for/master': not a Gerrit project
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

但是,如果我只是输入

git push someotherlocation.com:/path/to/code HEAD:refs/for/master

它被推送到 gerrit 服务器。为什么会这样,我做错了什么?谢谢!

【问题讨论】:

  • 什么是URI方案?是ssh://吗?将其包含在 URI 中是否有帮助?
  • 没有URI方案,只有git push someotherlocation.com:/path/to/code HEAD:refs/for/master。当我输入 ssh:// 时,它给了我一个错误,上面写着: ssh: 无法解析主机名 someotherlocation.com:: 节点名或提供的服务名,或未知致命:无法从远程存储库读取。请确保您具有正确的访问权限并且存储库存在。
  • 我也试过用 ssh:// 添加用户名和端口号,但还是不喜欢。

标签: git gerrit git-push


【解决方案1】:

您的 git remote 命令将推送 URL 设置为,字面意思是 someotherlocation.com:/path/to/code HEAD:refs/for/master。推送 URL 应该只是 URL。 push refspec (HEAD:refs/for/master) 不是 URL 的一部分。如果目标是避免每次都输入 refspec,我建议您考虑设置 Git 别名或研究 .gitconfig 的remote.<name>.push 选项(请参阅git-config(1))。

【讨论】:

  • 谢谢!我设置了git config --local remote.origin.push HEAD:refs/for/mastergit remote set-url --push origin someotherlocation.com:/path/to/code,现在只要输入git push 就可以了。再次,非常感谢!
猜你喜欢
  • 2021-07-14
  • 2019-06-23
  • 1970-01-01
  • 2018-06-29
  • 2018-02-07
  • 1970-01-01
  • 2017-12-06
  • 1970-01-01
  • 2013-06-23
相关资源
最近更新 更多