How to get the “committer” info that Git will use

Reading the doc, I see that I could predict what Git will use as “committer” by combining git config user.name and git config user.email along with $GIT_COMMITTER_NAME and $GIT_COMMITTER_EMAIL. But when I write the code which does that, I end up with the feeling that I’m rewriting a chunk of code that’s already in Git and I’d much rather reuse Git’s own code for that.

So, just like I prefer to use git rev-parse --git-dir rather than to look for a .git and/or check for $GIT_DIR, I’d like to use a command like git show-me-the --committer to get the usual NAME <EMAIL> string. Yet I haven’t been able to find this in the manual(s).

  • In Git, removing DLL and PDB files that have accidently been committed
  • Why to use SVN? Any hidden pros (over GIT/Mercurial/Bazaar) there?
  • How do I pull from another computer's repository in Git?
  • force git status to output color on the terminal (inside a script)
  • alternative to git-repo ( aosp repo )
  • How to get my git-integrated Kaleidoscope to display all files that are about to be committed?
  • Cannot push to Git with IntelliJ Idea12
  • git push sporadically fails on Jenkins with “Device not configured” error
  • Multiple commits cherry-picking
  • Discard changes in one single line
  • Modifying Git Diff files
  • Why doesn't the Travis git ref match my pull request sometimes?
  • One Solution collect form web for “How to get the “committer” info that Git will use”

    You can use the git var command:

    git var GIT_COMMITTER_IDENT
    

    This can be run outside of any Git worktree, prints the committer info in the format name <email> timestamp timezone, and uses the same Git code that also gets run when committing, so respects the configuration keys and environment variables. Depending on what you want to do with this info, you may need to filter out the timestamp and timezone.

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