Skip to content

Commit

Permalink
user-manual: finding commits referencing given file content
Browse files Browse the repository at this point in the history
Another amusing git exploration example brought up in irc.  (Credit to
aeruder for the complete solution.)

Signed-off-by: "J. Bruce Fields" <bfields@citi.umich.edu>
  • Loading branch information
J. Bruce Fields committed May 19, 2007
1 parent 8fae222 commit 187b0d8
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Documentation/user-manual.txt
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,22 @@ echo "git diff --stat --summary -M v$last v$new > ../diffstat-$new"
and then he just cut-and-pastes the output commands after verifying that
they look OK.

Finding commits referencing a file with given content
-----------------------------------------------------

Somebody hands you a copy of a file, and asks which commits modified a
file such that it contained the given content either before or after the
commit. You can find out with this:

-------------------------------------------------
$ git log --raw -r --abbrev=40 --pretty=oneline -- filename |
grep -B 1 `git hash-object filename`
-------------------------------------------------

Figuring out why this works is left as an exercise to the (advanced)
student. The gitlink:git-log[1], gitlink:git-diff-tree[1], and
gitlink:git-hash-object[1] man pages may prove helpful.

[[Developing-with-git]]
Developing with git
===================
Expand Down

0 comments on commit 187b0d8

Please sign in to comment.