2

I work in multiple branches of several git projects. I would like to get a list of my commits for specific date, in all of these projects and branches (for timesheets purposes).

While I could write an utility script for that purpose, I don't want to reinvent the wheel. Is there an easy way to do this, using existing unix-based tools or some git power-user recipe?

Lukas Stejskal
  • 2,542
  • 19
  • 30

2 Answers2

10

For a single repo:

git log --all --after="<date> 00:00" --before="<date> 23:59" --author="<author>"

<date> can be in any common format. <author> is case sensitive, and also checks the email address.

Note:

This looks at the committer date (when was this commit applied to this repository/branch), not the author date (when was this content first committed). This is important if you have rebased and/or cherry-picked. There does not appear to be equivalent functionality for author date.

Edit:

To get this log for a set of repositories, you can run:

for dir in repo1 repo2 ... repo_n; do
    git --no-pager --git-dir="$dir/.git" log --all \
        --after="<date> 00:00" \
        --before="<date> 23:59" \
        --author="<author>"
      && echo  # to add a blank line between logs
done
vergenzt
  • 9,669
  • 4
  • 40
  • 47
2

For working with multiple repositories you could use mr.

Define a custom action in .mrconfig, like eg.

[DEFAULT]
git_daylog = git log --branches --after="$* 00:00" --before="$* 24:00" --author="$(git config user.email)"

[gitrepos/my_blog_app]

[path_to_another_project_from_home]

...

and you will be able to say mr daylog 26 june and get your logs for all the repositories registered with mr under your current directory.

Lukas Stejskal
  • 2,542
  • 19
  • 30
Michał Politowski
  • 4,288
  • 3
  • 30
  • 41