【发布时间】:2013-04-05 02:07:16
【问题描述】:
考虑一个 git 存储库,其中一个文件曾经被删除。
git rm path/to/file
git commit -a -m"testing"
好的,现在我想查看文件的git log,但我收到了经典的错误消息:
git log path/to/file
fatal: ambiguous argument 'path/to/file': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions
解决方法很简单——添加--:
git log -- path/to/file
但是……为什么?为什么需要这个?这里的理由是什么? git 不能做一个有根据的猜测,这可能曾经是一个文件吗?我理解“歧义”问题 - 但从来没有那个名字的标签。如果文件曾经被删除,并且没有标签存在,那么选择“文件解释”总是不错的选择。
另一方面,可以有一个与文件同名的标签,git log 处理得很好:
fatal: ambiguous argument 'path/to/file': both revision and filename
Use '--' to separate filenames from revisions
这种行为似乎不一致。谁能解释一下 git 的开发者的想法?
【问题讨论】: