Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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.

like image 288
Jeffrey Harris Avatar asked Sep 28 '11 17:09

Jeffrey Harris


People also ask

How do I blame a file in git?

The git blame command is used to examine the contents of a file line by line and see when each line was last modified and who the author of the modifications was. The output format of git blame can be altered with various command line options.

What does blame mean in GitHub?

From GitHub: The blame command is a Git feature, designed to help you determine who made changes to a file. Despite its negative-sounding name, git blame is actually pretty innocuous; its primary function is to point out who changed which lines in a file, and why.

How do you use blame?

to think or say that someone or something is responsible for something bad blame somebody/something (for something) She doesn't blame anyone for her father's death. A dropped cigarette is being blamed for the fire. blame something on somebody/something Police are blaming the accident on dangerous driving.

Why is it called git blame?

In case you don't know git-blameIf you want to know who last changed a particular chunk of code, you use Git to run a special command. That command is called blame. In other words, you don't ask who the author is, you ask who's to blame for a particular contribution.


1 Answers

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 
like image 168
knittl Avatar answered Oct 19 '22 22:10

knittl