Skip to content

Instantly share code, notes, and snippets.

@sebastianha sebastianha/.gitconfig
Last active Jan 11, 2017

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

commented Jan 11, 2017

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
You can’t perform that action at this time.