show history of a file?

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.

  • Right click on a file and select history.
  • 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.

  • "git log filename"
  • Look at history and pick a date, copy hash
  • "git diff hash"
  • Scroll through diff for the stuff that changed in the file I am interested in.
  • 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.


    你有没有试过这个:

    gitk path/to/file
    

    您可以使用git log在搜索时显示差异:

    git log -p -- path/to/file
    

    git log -p will generate the a patch (the diff) for every commit selected. For a single file, use git log --follow -p $file .

    If you're looking for a particular change, use git bisect to find the change in log(n) views by splitting the number of commits in half until you find where what you're looking for changed.

    Also consider looking back in history using git blame to follow changes to the line in question if you know what that is. This command shows the most recent revision to affect a certain line. You may have to go back a few versions to find the first change where something was introduced if somebody has tweaked it over time, but that could give you a good start.

    Finally, gitk as a GUI does show me the patch immediately for any commit I click on.

    Example 在这里输入图像描述 :

    链接地址: http://www.djcxy.com/p/22656.html

    上一篇: 获取仅关于1个文件夹的提交日志

    下一篇: 显示文件的历史记录?