git config --global user.email "some@email.com" throws "error: only one config file at a time."

StackOverflow https://stackoverflow.com/questions/22841295

  •  27-06-2023
  •  | 
  •  

سؤال

Using git config user.email "some@email.com" sets user email in global config file.

Using git config --global user.email "some@email.com" or git config --local user.email "some@email.com" (from within a repo) throws:

"error: only one config file at a time."

My global .gitconfig:

[color]
  ui = auto
[user]
  name = My Name
  email = my@email.com
[alias]
  co = checkout
  ci = commit
  st = status
  br = branch
  hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
  lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%C(bold blue)<%an>%Creset' --abbrev-commit
  type = cat-file -t
  dump = cat-file -p
[push]
  default = simple
[core]
  autocrlf = true

What should I change to be able to have separate user.name/email for global config and local/repo config?

هل كانت مفيدة؟

المحلول

git config --global does not seem to work when the environment variable GIT_CONFIG is set.

Try to unset GIT_CONFIG and then list your global config with

unset GIT_CONFIG
git config --global --list

نصائح أخرى

Havin come to a similar issue after setting up $GIT_CONFIG, I fully confirm @dpat's answer.

git help config:

ENVIRONMENT
    GIT_CONFIG
       Take the configuration from the given file instead of .git/config. Using the
       "--global" option forces this to ~/.gitconfig. Using the
       "--system" option forces this to $(prefix)/etc/gitconfig.

is simply missleading (ie used for local repo, not --global). Git checks for the global configuration only in the four places that @Cupcake linked to.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top