Reputation: 913
I want to annotate/blame a file in a git repository on a revision using the following command:
git annotate [options] file [revision]
However, the file does not exist in the current repository anymore, but I know that the file was exist in revision f80133a.
git annotate java/org/apache/catalina/valves/CometConnectionManagerValve.java f80133a
fatal: cannot stat path 'java/org/apache/catalina/valves/CometConnectionManagerValve.java': No such file or directory
Is there simple way to annotate a deleted file without checking out the revision f80133a in this situation?
Upvotes: 0
Views: 244
Reputation: 198436
git stash # if you have pending changes
git checkout f80133a
git annotate java/org/apache/catalina/valves/CometConnectionManagerValve.java > annotation.txt
git checkout master # or develop, or wherever you were
git stash pop # if stashed
EDIT after OP's edit: without checking out, I don't think so, but I may be wrong.
EDIT2: I am wrong. You can also trick git:
touch java/org/apache/catalina/valves/CometConnectionManagerValve.java
git annotate java/org/apache/catalina/valves/CometConnectionManagerValve.java f80133a
rm java/org/apache/catalina/valves/CometConnectionManagerValve.java
Upvotes: 2
Reputation: 1120
for the instance you can checkout to that commit to see the blame like
git checkout f80133a
after this you will reach that commit in a detached head state then do blame
git annotate [options] file
and once you are done
git checkout your_prev_branch_name
Upvotes: 0