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_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).
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.