Show history of a file?

Chris picture Chris · Mar 21, 2012 · Viewed 164.4k times · Source

Possible Duplicate:
View the change history of a file using Git versioning

Sometimes I want to step through the history of a particular file. In the past I used P4V and this was very quick and intuitive.

  1. Right click on a file and select history.
  2. Scrolling through the dates and see a nice diff of exactly what changed in that file on that date. Simple.

Switching to git this is now a grueling task.

  1. "git log filename"
  2. Look at history and pick a date, copy hash
  3. "git diff hash"
  4. Scroll through diff for the stuff that changed in the file I am interested in.
  5. Nope, that's not it, lets try a different date - back to step 2, rinse and repeat.

I've searched SO, and I've tried a few of the commonly suggested guis: github, gitk, gitg, git-gui.

These all remove the need to manually run commands, but the workflow is the same for this. View history of file; view commit; search through diff of lots of irrelevant files. It's slow and repetitive.

All the data is in the repo so I see no reason this simple common use case could not be more streamlined.

Can anyone recommend a tool that does this - or a more efficient way to utilize the command line to do what I want?

Thanks for any suggestions.

Answer

ralphtheninja picture ralphtheninja · Mar 21, 2012

You can use git log to display the diffs while searching:

git log -p -- path/to/file