Sample Header Ad - 728x90

Is there a way to disallow a certain combination of commands and options?

0 votes
1 answer
72 views
Say, I create a new repo, and try to commit. Git shows me
*** 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.
Without reading the last line, I run the two lines suggested by git (with --global) and happily commit. A week later I create a new repo for a completely unrelated project where I'd need to commit under a different user.email. Without even thinking about user.email, I try to commit, it goes through and I push to the origin. The above happened to me twice and made me think whether there is a way to disallow git config --global. For example, if I run
git config --global user.email "you@example.com"
I'd like bash not to run the command and show me a warning, but when I run
git config user.email "you@example.com"
I'd like it to go through. Is it possible?
Asked by Leo (103 rep)
Dec 30, 2021, 06:52 PM
Last activity: Jan 1, 2022, 01:53 PM