How can I use git to provide a word count graph?

I’m writing a long piece of prose and want to use git to track the word count. (Not a graph of commits, which is well documented.)

How can I plot a graph of word count vs time (or word count vs commit)?

  • Git, sub-repos & external libs for web development - best strategy once and for all?
  • How to save config for merged-remotes in a git repository?
  • Automatic documentation verification with Aspell before Commit
  • Bower refuses to install from github fork
  • How do I do git pull so that it will update the files in the working
  • Moving subfolder from one git repo to another preserving history
  • How to create an empty branch for documentation
  • Using GIT to update files on local fileserver
  • git push failed The remote end hung up unexpectedly
  • How does git mergetool work to resolve conflicts?
  • GIT: What happens during branching?
  • In Gerrit how do I squash multiple reviews into one review
  • One Solution collect form web for “How can I use git to provide a word count graph?”

    AFAIK, git doesn’t have a feature for word counting, let alone drawing graphs of word counts. However, you can combine git and other tools to do that.

    For example, this will output word counts for each commit that changed file.txt file:

    git rev-list HEAD -- file.txt |
        while read c; do git show "$c:file.txt" | wc -w; done
    

    And this will output the same along with commit timestamps:

    git rev-list --timestamp HEAD -- file.txt |
        while read t c; do echo -n "$t "; git show "$c:file.txt" | wc -w; done
    

    You can feed this output to gnuplot, or paste it into openofice.org Calc to plot a graph.

    Git Baby is a git and github fan, let's start git clone.