To me it looks like the following situation:
Say, we are talking about file foo.txt
that was added to git repository (say, empty) at some point:
touch foo.txt
git add foo.txt
git commit -m "added foo.txt"
// commit '123'
Then it was changed a couple of times:
// add "hello" to foo.txt
git add foo.txt
git commit -m "Added 'hello'"
// commit '456'
// add "world" to foo.txt
git add foo.txt
git commit -m "Added 'world'"
// commit '789'
At this point the file (that contains 'hello world') gets copied aside (cp foo.txt /tmp/foo.txt
) and its the reference copy.
Afterwards there were other commits that altered the content of foo.txt
, say commits abc
, def
) so that the file now actually looks in git like:
Hello world
How are you doing?
I'm fine, and you?
I'm Ok too
So the question that is actually asked is how to find the commit after which the file foo.txt
looks exactly like a reference copy, as its stored in /tmp/foo.txt
: it contains only "Hello world" (commit 789
in my example)
In this case I believe you should use git bisect
command, give it boundaries of the last commit and the first (initial commit) and, if there are were many commits in the project, running a binary search will be much faster than iterating over all the commits in the history of the file.
Read about it here
You should know how to take a decision whether the commit is 'good' or 'bad' in terms of git bisest
(e.g. whether it contains the words 'hello' and 'world' for example)