Consider a git repository, where a file was once deleted.
git rm path/to/file
git commit -a -m"testing"
Ok, now I want to see the git log
for the file, but I receive the classic error message:
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
The solution is simple - add --
:
git log -- path/to/file
But... why? Why is this needed? What is the rationale here? Can't git do an educated guess, that this might have been a file once? I understand the "ambiguity" problem - but there never was a tag by that name. If the file was once deleted, and no tag is present, then choosing "the file interpretation" is always the good choice.
On the other hand, it's possible to have a tag named the same as a file, which git log
handles pretty well:
fatal: ambiguous argument 'path/to/file': both revision and filename
Use '--' to separate filenames from revisions
This behavior seems inconsistent. Could anyone explain what the developers of git had in mind?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…