致命:refspec 的远程部分不是 .git/refs/heads/master:.git/refs/remotes/origin/master 中的有效名称

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7316352/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 05:57:22  来源:igfitidea点击:

fatal: remote part of refspec is not a valid name in .git/refs/heads/master:.git/refs/remotes/origin/master

git

提问by Terry

I know that it would be easier to use git push origin master, but if I do:

我知道使用会更容易git push origin master,但如果我这样做:

git push origin .git/refs/heads/master:.git/refs/remotes/origin/master 

I get:

我得到:

fatal: remote part of refspec is not a valid name in .git/refs/heads/master:.git/refs/remotes/origin/master

致命:refspec 的远程部分不是 .git/refs/heads/master:.git/refs/remotes/origin/master 中的有效名称

Why doesn't this work?

为什么这不起作用?

I'm only trying to follow:

我只是想遵循:

git push [remotename] [localbranch]:[remotebranch]

回答by CB Bailey

Refspecs aren't relative path names, "absolute" refspecs just start with refs/. The most "absolute" version of what you are trying to push would be:

Refspecs 不是相对路径名,“绝对”refspecs 只是以refs/. 您尝试推送的最“绝对”版本是:

git push origin refs/heads/master:refs/remotes/origin/master

However, this is notequivalent to git push origin master. What this does is updates the remote's remote tracking branch origin/masterso that it may or may not reflect what its remote originis actually at.

但是,这等同于git push origin master. 这样做是更新遥控器的远程跟踪分支,origin/master以便它可能会或可能不会反映其遥控器origin的实际位置。

The equivalent of git push origin master would be:

git push origin master 的等价物是:

git push origin refs/heads/master:refs/heads/master