Last active
January 11, 2017 14:44
-
-
Save sebastianha/8742361f107efe0ac14f to your computer and use it in GitHub Desktop.
Prevent GIT from commiting when user / email has not been adjusted for repo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Everytime I clone a new GIT repo I always forget to set the user information to the specific values (privat, company, whatever) | |
# This entry in my .gitconfig prevents commiting as long I have not edited the local .git/config | |
# | |
# This workaround is based on the following stack-overflow question: http://stackoverflow.com/a/25050535 | |
[user] | |
email = (none)\n\n\n====================================\n!!! E-MAIL NOT SET FOR THIS REPO !!!\n!!! Specify your name and e-mail !!!\n====================================\n\n\n | |
name = Firstname Lastname | |
# The result is the following: | |
# | |
# $> git commit -m "test" | |
# | |
# *** Please tell me who you are. | |
# | |
# Run | |
# | |
# git config --global user.email "[email protected]" | |
# git config --global user.name "Your Name" | |
# | |
# to set your account's default identity. | |
# Omit --global to set the identity only in this repository. | |
# | |
# fatal: unable to auto-detect email address (got '(none) | |
# | |
# | |
# ==================================== | |
# !!! E-MAIL NOT SET FOR THIS REPO !!! | |
# !!! Specify your name and e-mail !!! | |
# ==================================== | |
# | |
# | |
# ') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Now it can be done by config value:
git config --global user.useConfigOnly true
Source: http://stackoverflow.com/questions/12292582/how-do-i-make-git-block-commits-if-user-email-isnt-set