Monday, February 7, 2011

Using git to grep through a file's previous versions?

Is there a command that would allow me to check if the string "xyz" was ever in file foo.c in the repository and print which revisions they were found in?

  • This will print any commits where the diff contains xyz

    git log -Sxyz foo.c

  • I know you can do this with gitk, you can search for commits "adding/removing string" and give it some text to look for. There's a way to do this from the command line too, but I don't recall off the top of my head.

0 comments:

Post a Comment