1

I would like to get the history of commit messages for a given author in a git branch. Is there any easy way to achieve it other than to parse the log through programming?

UPDATED:

The following was expacted for me that does the same thing:

git log --author='some author' --pretty=oneline --abbrev-commit
git log --author='some author' --oneline

git log --help mentioned the follows:

   Commit Formatting
       --pretty[=<format>], --format=<format>
           Pretty-print the contents of the commit logs in a given format, where <format> can be one of oneline, short, medium, full, fuller, email, raw and
           format:<string>. See the "PRETTY FORMATS" section for some additional details for each format. When omitted, the format defaults to medium.

           Note: you can specify the default pretty format in the repository configuration (see git-config(1)).

       --abbrev-commit
           Instead of showing the full 40-byte hexadecimal commit object name, show only a partial prefix. Non default number of digits can be specified
           with "--abbrev=<n>" (which also modifies diff output, if it is displayed).

           This should make "--pretty=oneline" a whole lot more readable for people using 80-column terminals.

       --no-abbrev-commit
           Show the full 40-byte hexadecimal commit object name. This negates --abbrev-commit and those options which imply it such as "--oneline". It also
           overrides the log.abbrevCommit variable.

       --oneline
           This is a shorthand for "--pretty=oneline --abbrev-commit" used together.
caot
  • 3,066
  • 35
  • 37

3 Answers3

3

git log --author=<author>

If say you are looking for adam Brown commits

git log --author="adam"

git log --author=adam

git log --author=Brown

would also work. The quotes are optional if you don't need any spaces.

Add --all if you intend to search all branches and not just the current commit's ancestors in your repo.

So to list commits by adam or damian, you can do a regex like this:

git log --author="\(damian\)\|\(adam\)"

or

git log --committer="\(damian\)\|\(amit\)"

amittn
  • 2,249
  • 1
  • 12
  • 19
2

You have to give Author name as registered in GIT repo. Or the Author email address will also work.

e.g.

git log --author='Bharat Biswal'
git log --author='bharat.biswal@gmail.com'

enter image description here

Bharat Biswal
  • 1,755
  • 2
  • 15
  • 23
1

git log --author=<author name pattern>
check the man page of git log for details.

Ashwani
  • 1,938
  • 11
  • 15