Search code examples
gitgit-log

How to print out each version of a given file in "git log"?


We can generate a patch for each version of a given file by:

git log -p -- <filename>

But it only shows the diff of each version, I want it to show the full content of the file at each version, so I can next parse the output as my demand. Does git log support this?


Solution

  • Quickest hack I can think of is to parse fast-export output, it's not hard,

    git fast-export --all -- path/to/file
    

    and if you're using commit signing or tagging objects other than commits you'll need to add some options to filter those out.