I use Git heavily with different usernames on different machines. Sometimes, when I clone a repository, I forget to configure user.nameboth and user.email, and when I commit the first commit to a local repository without a specified name, I get
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:
git config
git config
After doing this, you may fix the identity used for this commit with:
git commit
Yes, it’s very clear what and why Git says so. (If I notice him). However, is it possible to suppress this behavior and prevent Git from propagating my username and hostname as the commit username? Why do I ask a question that I do not have [user] name =, and [user] email =in my ~/.gitconfigon a plan: I just use different user names and e-mails to different groups of repositories, and I would like to Git interrupted the commit, if he can not get the user name and e-mail address from configuration. The worst part is that I have a custom git-informativePS1 configured to display the current username and email address on the right, because I had a history of rewriting and pushing several times before I even noticed that there were huge Git warnings for the default username.
Is it possible to abort a commit in Git if user.nameit has user.emailnot been specified by me all over the world? (I suppose this can be fixed with hooks, but the hooks are only local, right?)
source
share