23

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.

Jeffrey Harris
  • 3,480
  • 25
  • 30

1 Answers1

26

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
knittl
  • 246,190
  • 53
  • 318
  • 364
  • Either order works if the file in question hasn't moved, at least in recent git versions. As it turns out, I normally use the right order, but when I was constructing the question I cut and pasted from the wrong set of attempts. Anyway, thanks for the magic of the -- delimiter, that's what I was missing! – Jeffrey Harris Oct 13 '11 at 21:39