git推送到gerrit服务器不';设置git remote set url--push时不起作用,但是如果我手动输入url,它就起作用

git推送到gerrit服务器不';设置git remote set url--push时不起作用,但是如果我手动输入url,它就起作用,git,gerrit,git-push,Git,Gerrit,Git Push,我无法将代码从git推送到gerrit。首先,我检查了代码,如下所示: git克隆ssh://user@location.com:22/path/to/code 然后我尝试设置一个推送url,如下所示: git远程设置url——推送来源“someotherlocation.com:/path/to/code HEAD:refs/for/master” 当我执行git push时,它返回以下错误: fatal: '/path/to/code HEAD:refs/for/master': not a

我无法将代码从git推送到gerrit。首先,我检查了代码,如下所示:

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

然后我尝试设置一个推送url,如下所示:

git远程设置url——推送来源“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服务器。为什么会这样,我做错了什么?谢谢

您的
git remote
命令将推送URL按字面意思设置为
someotherlocation.com:/path/to/code HEAD:refs/for/master
。推送URL应仅为URL。推送参考规范(
标题:refs/for/master
)不是URL的一部分。如果目标是避免每次都必须键入refspec,我建议您考虑设置Git别名,或者研究.gitconfig的
remote..push
选项(请参阅)。

URI方案是什么?是ssh://吗?将其包含在URI中是否有帮助?没有URI方案,它只是
git push someotherlocation.com:/path/to/code HEAD:refs/for/master
。当我放置ssh://时,它给了我一个错误:ssh:无法解析主机名someotherlocation.com::nodename或提供的servname,或者未知致命:无法从远程存储库读取。请确保您具有正确的访问权限,并且存储库存在。我还尝试使用ssh://添加用户名和端口号,但它仍然不喜欢。谢谢!我设置了
git config--local remote.origin.push HEAD:refs/for/master
git remote set url--push origin someotherlocation.com:/path/to/code
,现在我只要输入
git push
就可以了。再次感谢!