user1200257
user1200257

Reputation:

git blame for files that don't exist in current branch

I have a file that exists in branch_A but does not exist in branch_B.

I want to run

> git checkout branch_B
> git blame branch_A file

However, git complains that I don't have the file locally - which is correct but ignores the fact that I want to blame relative to branch_A. I would expect git blame to check for file existence relative to the desired branch instead of the checked-out branch.

I can trick git blame to do what I want if I run this when on branch B:

> touch file
> git blame branch_A file

Is there a straightforward way of doing this?

Upvotes: 11

Views: 4445

Answers (1)

user1200257
user1200257

Reputation:

Apparently the way to do this is with:

> git blame branch_A -- file

instead of

> git blame branch_A file

Upvotes: 16

Related Questions