问题描述
上下文:我正在制作一个工具来分析2个分支之间的差异。我想看一下origin/develop
和origin/release
上的提交历史。由于仅需要历史记录,因此仅克隆了历史记录(git clone --bare
)
在git fetch
之后,我希望查看发布和开发中的最新提交,而不必在每个分支上都git merge origin/develop|release
。所以我尝试只是git log origin/develop [... format options]
。
在某些项目上,它可以按预期工作。但是在一个特定的项目上,我得到这个错误:
$ git log origin/develop master * ] 11:01
fatal: ambiguous argument 'origin/develop': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions,like this:
'git <command> [<revision>...] -- [<file>...]'
如果我尝试git remote -v
,可以看到origin
的定义正确。 origin/develop
怎么可能不是有效的修订版本?
解决方法
引用the documentation of the --bare
flag:
还可以将远程的分支头直接复制到相应的本地分支头,而无需将它们映射到
refs/remotes/origin
如果克隆存储库时没有git log
标志,则此--bare
选项将起作用。
编辑:
要回答评论中的问题,这还意味着您可以直接调用git log <branchname>
,而无需参考origin/<branchname>
。也就是说,在您的情况下:
git log develop