0

If I have a specific string how can I use e.g git log to find the email of the committer from the command line?
I don't want to see the commit. I only want the "one-liner" command to give me only the email of the author.

NOTE: I do NOT have a commit id. I only have a search string. I mean a string that I know is part of a commit for sure.

Update after comment from @axiac:
I have a string X that is "unique" in the sense that is introduced by only 1 committer. The committer adds it to file foo.java.
I want having only the string X and foo.java to find the email of the commiter who added the string

Jim
  • 18,826
  • 34
  • 135
  • 254
  • 1
    *"I only have a string"* - you have to be more specific. What string do you have? I guess it's not the committer's email, you said it's not a commit hash. What is it then? A fragment from the commit message? A fragment from a file? Do you know the name of the file? – axiac Aug 23 '15 at 17:32
  • @axiac:It is just a string that I know for sure it is part of *a* commit. – Jim Aug 23 '15 at 18:12
  • 1
    It's still not clear. All the strings mentioned above (committer's name and email, commit message, commit date, file names and contents) are part of the commit. Which one is the one you know? – axiac Aug 23 '15 at 18:18
  • @axiac: I only have a string that is "unique" in a sense that 99% of the time it will be introduced/affected by only 1 commiter. I did not have a specific file in mind but now that you mention it, it is for certain part of a certain file e.g. `foo.java`. I only need the email of the commiter – Jim Aug 23 '15 at 19:47
  • Try `git log` with the `-G` option – Andrew C Aug 24 '15 at 04:31
  • @AndrewC: Just `-G`? – Jim Aug 24 '15 at 17:53
  • No, more like `git log -G --pretty=%ce` You may need to pass in additional ref-specs if the commit you are after isn't reachable from HEAD. – Andrew C Aug 24 '15 at 19:00
  • @AndrewC:I am sorry for my question, but I don't know what "additional ref-specs" is supposed to be – Jim Aug 24 '15 at 20:12
  • Just pass in `--all` to be safe – Andrew C Aug 25 '15 at 16:11
  • Relevant question. Why so many downvotes? @Avalanche's answer is helpful. – Manu Manjunath Jan 18 '21 at 07:41

2 Answers2

7
git --no-pager log -s --format="%ae"

Source.

Avalanche
  • 1,468
  • 1
  • 11
  • 18
1

How about git log --grep="YOUR_SEARCH_REGEX" --pretty=format"%ce"

David Neiss
  • 8,161
  • 2
  • 20
  • 21