Q:

how to count SLOC of git library according to date

For example, count the SLOC of git with the given date(2 years ago or else).
And I have another question:
    How to figure out the top 10 program files and top 5 components that are modified the most
(have the largest total number of changed lines of code or have the largest number of modifications)in git library with given date?

A:

You can adapt this ruby script, which calls git diff --stat in order to get those statistics.
For python, you have "git-loc"
2010-05-13 14:38:21       42   +44    -2     initial
2010-05-13 14:40:14       44    +3    -1     hashbang added
2010-05-13 14:40:14       49    +8    -3     show last commit too

Run it as `git-loc --svg' to output svg graph on stdout.

See git rev-parse SPECIFYING REVISIONS to check how to use dates:

<refname>@{<date>}, e.g. master@{yesterday}, HEAD@{5 minutes ago}
A ref followed by the suffix @ with a date specification enclosed in a brace pair (e.g. {yesterday}, {1 month 2 weeks 3 days 1 hour 1 second ago} or {1979-02-26 18:30:00}) specifies the value of the ref at a prior point in time.

You can combine those git diff or git log commands with "Finding most changed files in git":
git log --pretty=format: --name-only | sort | uniq -c | sort -rg | head -10

