Skip to content

Instantly share code, notes, and snippets.

@sebastianha
Last active January 11, 2017 14:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebastianha/8742361f107efe0ac14f to your computer and use it in GitHub Desktop.
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
# 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 "you@example.com"
# 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 !!!
# ====================================
#
#
# ')
@sebastianha
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment