Mark is a graph advocate and field engineer for Neo Technology, the company behind the Neo4j graph database. As a field engineer, Mark helps customers embrace graph data and Neo4j building sophisticated solutions to challenging data problems. When he's not with customers Mark is a developer on Neo4j and writes his experiences of being a graphista on a popular blog at He tweets at @markhneedham. Mark is a DZone MVB and is not an employee of DZone and has posted 532 posts at DZone. You can read more from them at their website. View Full User Profile

Git: Getting the history of a deleted file

  • submit to reddit

We recently wanted to get the Git history of a file which we knew existed but had now been deleted so we could find out what had happened to it.

Using a simple git log didn’t work:

git log deletedFile.txt
fatal: ambiguous argument 'deletedFile.txt': unknown revision or path not in the working tree.

We eventually came across Francois Marier’s blog post which points out that you need to use the following command instead:

git log -- deletedFile.txt

I’ve tried reading through the man page but I’m still not entirely sure what the distinction between using and not using it is supposed to be.

If someone could explain it that’d be cool…


Published at DZone with permission of Mark Needham, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)


Mason Mann replied on Mon, 2011/10/10 - 3:08am

The "--" purely a linux shell thing. It basically says "there will be no more options on this line", which is required since git log expects a revrange.

Wujek Srujek replied on Mon, 2011/10/10 - 9:01am in response to: Mason Mann

It actually has nothing to do with shells, it is just a string that some applications (like rm, and git among others) are kind enough to support and treat specially. To test just write a simple script with that inside: #!/bin/bash echo "$@" and call it: a b c -- d e The output: a b c -- d e which proves only that -- is just a normal argument, no shell pre-procesing takes place. I tested with bash, but it works just the same with others.

Mason Mann replied on Mon, 2011/10/10 - 1:21pm

It doesn't matter if it's actually a shell thing or not - from the user perspective it's just a way to say "there will be no more options on this line" on the shell. Don't make things harder than you need to, bozo.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.