One of the reason for this question is that I cannot find username (committer reported in example below) in any of the files:
grep -r obsdev .git/config ~/.gitconfig /etc/gitconfig
# no output
Apparently, there is another configuration source.
The point is that I don't want to learn about any possible configuration source existing now, or in the future, or order in which they apply and override each other. Instead, I want to let Git figure out and display final/effective author/committer values.
Under some conditions (like command line option --author) Git displays commented out Author: and Committer: fields in editor for commit message:
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Author: First Last <[email protected]>
# Committer: username <[email protected]>
#
...
Is there a way to show these fields without trying to make a commit?
Alternatively, is it possible to force Git provide comments containing Author: and Committer: fields in the commit message editor under any circumstances without any command line options even when defaults are used (without overriding defaults)?
You can use git var:
# show the author (sed is there to strip the timestamp)
git var GIT_AUTHOR_IDENT | sed -r 's/( [^ ]+){2}$//'
# and the committer
git var GIT_COMMITTER_IDENT | sed -r 's/( [^ ]+){2}$//'
But if you haven't configured your name and email, it will print a warning instead of giving a value. A workaround would be:
# show the author
git var -l | grep -E '^GIT_AUTHOR_IDENT=' | sed -r 's/^[^=]+=//;s/( [^ ]+){2}$//'
# and the committer
git var -l | grep -E '^GIT_COMMITTER_IDENT=' | sed -r 's/^[^=]+=//;s/( [^ ]+){2}$//'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With