Can I configure git so it does not guess user.email configuration settings?

后端 未结 5 1902
余生分开走
余生分开走 2021-02-14 14:39

On my system I don\'t have the user.email git configuration value set at the global level, on purpose. Instead, I configure it individually in each sandbox. This is

5条回答
  •  长情又很酷
    2021-02-14 15:39

    There is a config option for that now.

    user.useConfigOnly

    Instruct Git to avoid trying to guess defaults for user.email and user.name, and instead retrieve the values only from the configuration.

    So just set this to true like this:

    git config --global user.useConfigOnly true
    

    And next time when you try to make a commit without user.email and user.name explicitly set you will get an error.

    $ git commit
    
    *** 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: no email was given and auto-detection is disabled
    

提交回复
热议问题