Search code examples
gitblame

Blame on an earlier version of a file in a different location


At one point my git repository had its paths reorganized.

I often want to do a blame on a file at a revision before the move.

What's the git blame incantation to blame a file that doesn't exist in the current repository?

I tried:

> git blame new/path/to/file old_rev
fatal: no such path ... in old_rev

> git blame old/path/to/file old_rev
fatal: cannot stat path ... in old_rev

> git blame old_rev:old/path/to/file old_rev
fatal: cannot stat path ... in old_rev

Clearly I could just check out old_rev and blame the appropriate path, but I'd rather avoid that.


Solution

  • You can use git blame --follow to make blame follow your renames.

    I also see your parameters are in the wrong order, try the following:

    git blame old_rev -- old/path/to/file