git config --global user.email "[email protected]" 抛出“错误:一次只有一个配置文件。”

问题描述 投票:0回答:3

使用

git config user.email "[email protected]"
global 配置文件中设置用户电子邮件。

使用

git config --global user.email "[email protected]"
git config --local user.email "[email protected]"
(在存储库中)会抛出:

“错误:一次只有一个配置文件。”

我的全球

.gitconfig
:

[color]
  ui = auto
[user]
  name = My Name
  email = [email protected]
[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

我应该更改什么才能为全局配置和本地/存储库配置提供单独的用户名/电子邮件?

git git-config
3个回答
12
投票

设置环境变量 GIT_CONFIG 时,git config --global 似乎不起作用。

尝试取消设置 GIT_CONFIG,然后列出您的全局配置

unset GIT_CONFIG
git config --global --list

0
投票

Havin 在设置 $GIT_CONFIG 后遇到了类似的问题,我完全确认@dpat 的回答。

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.

只是误导(即用于 local repo,而不是 --global)。 Git 仅在 @Cupcake 链接到的四个位置检查全局配置。


0
投票

有史以来最愚蠢的问题。不过,很好的答案。

© www.soinside.com 2019 - 2024. All rights reserved.