简体   繁体   English

致命的:无效的refspec'+ refs / heads / *'

[英]fatal: Invalid refspec '+refs/heads/*'

In git-fetch doc, you can see: git-fetch doc中,您可以看到:

The remote ref that matches <src> is fetched, and if <dst> is not empty string , the local ref that matches it is fast-forwarded using <src>. 获取与<src>匹配的远程ref,如果<dst>不是空字符串 ,则使用<src>快速转发与之匹配的本地ref。 If the optional plus + is used, the local ref is updated even if it does not result in a fast-forward update. 如果使用了可选的加号+,则本地引用会更新,即使它不会导致快速转发也是如此。

So we can use empty string as destination . 因此我们可以将empty string as destination Now my current repository has a remote which it's name is origin . 现在我当前的存储库中有一个名为origin的远程服务器。 When I try to fetch like this, I get an error: 当我尝试像这样获取时,出现错误:

git fetch origin +refs/heads/*
fatal: Invalid refspec '+refs/heads/*'

But why an empty string cause invalid refspec ? 但是,为什么一个empty string会导致invalid refspec

When I try to fetch like this, I get an error: 当我尝试像这样获取时,出现错误:

You don't need to supply information to the fetch this way. 您不需要通过这种方式提供信息。

You can use it like this (no need to define the ref themself): 您可以这样使用它(无需自己定义ref):

# fetch all ref
git fetch 

# fetch a specific ref
git fetch origin 

The format of a parameter is an optional plus +, followed by the source ref , followed by a colon :, followed by the destination ref . 参数的格式是可选的plus +,后跟源ref,后跟冒号:,然后是目标ref。 The colon can be omitted when is empty. 空的冒号可以省略。

The refspec descriptions in all of the git documentation are generally a bit poor, in part because all this stuff evolved over time and the current best practice refspecs were only invented for git version 1.5, with older methods still being supported today. 所有git文档中的refspec描述通常都比较差,部分原因是所有这些东西都随着时间的推移而发展,并且当前的最佳实践refspec仅针对git 1.5版才被发明,而今天仍支持较旧的方法。

In any case, shell glob style * matches are limited ( less so in git 2.6 than they were before). 在任何情况下,shell glob样式*匹配都受到限制( 在git 2.6中比以前更少了 )。 One limitation is requiring full pairs: That is, you cannot use a wildcard match * on the left side of a fetch refspec without having a corresponding * on the right. 一个限制是需要全对:也就是说,你不能使用通配符*上获取的Refspec左侧不具有相应*在右边。 This is why git winds up rejecting your empty refspec, even though it should logically work on the command line (in that it should be able to drop any matching ref into FETCH_HEAD ). 这就是为什么混帐卷起拒绝您空的Refspec,即使它理应在命令行上工作(因为它应该能够匹配任何参考拖放到FETCH_HEAD )。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Git远程命令返回致命:无效的refspec + refs / heads / *:refs / remotes /:origin / * - Git remote command returns fatal: Invalid refspec +refs/heads/*:refs/remotes/:origin/* 致命:refspec的远程部分不是.git / refs / heads / master中的有效名称:.git / refs / remotes / origin / master - fatal: remote part of refspec is not a valid name in .git/refs/heads/master:.git/refs/remotes/origin/master Git致命:引用的格式无效:'refs / heads / master - Git fatal: Reference has invalid format: 'refs/heads/master 致命:参考格式无效:&#39;refs / heads / master~&#39; - fatal: Reference has invalid format: 'refs/heads/master~' Git 致命:坏 object refs/heads 2/master - Git fatal: bad object refs/heads 2/master libgit2返回:在TortoiseGit中找不到Refspec&#39;refs / heads / origin / HEAD&#39;错误 - libgit2 returned: Refspec 'refs/heads/origin/HEAD' not found error in TortoiseGit git 推送错误:dst refspec refs/heads/main 匹配多个 - git push error: dst refspec refs/heads/main matches more than one 致命:当gerritpick版本修订时,歧义参数&#39;refs / heads / refs / heads / xxxbranch&#39; - fatal: ambiguous argument 'refs/heads/refs/heads/xxxbranch' when cherrypick Revision in gerrit Git:引用格式无效:“ refs / heads / SomeBranch” - Git: Reference has invalid format: 'refs/heads/SomeBranch' git pull origin master 返回致命:无效的 refspec - git pull origin master returns fatal: invalid refspec
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM