git config 全局文件 - 删除设置

got*_*tqn 101 git

以下命令:

$git config --global --list
Run Code Online (Sandbox Code Playgroud)

给我:

user.name=test user
user.name=gotqn
Run Code Online (Sandbox Code Playgroud)

我想删除名字。我参考了这篇文章,做了以下命令,但没有任何结果:

git config --global --remove-section user.name='test user'
git config --global --remove-section user.name="test user"
git config --global --remove-section user.name=test user
git config --global --remove-section user.name
git config --global --remove-section test user
Run Code Online (Sandbox Code Playgroud)

我正在使用 Ubuntu 12.04 和

git version
Run Code Online (Sandbox Code Playgroud)

给我

git version 1.7.9.5
Run Code Online (Sandbox Code Playgroud)

请对此提供帮助,因为我想尝试使用 git 保存我的项目,但不想使用“测试用户”名称执行命令。

Mar*_*ppi 110

您可以编辑~/.gitconfig主文件夹中的文件。这是--global保存所有设置的地方。

  • @Giri 或者你可以使用 `vim`... 或 `ex` 或 `ed` 或 `butterflies 将宇宙能量集中在高层大气中,然后翻转驱动盘中的正确位`。 (4认同)
  • 谢谢,那行得通,但是有没有办法也可以使用命令来编辑它? (2认同)
  • @gotqn `gedit ~/.gitconfig` 或 `nano ~/.gitconfig` (2认同)

小智 99

超级迟到的答案,但希望仍然有帮助:

git config --global --unset-all user.name
Run Code Online (Sandbox Code Playgroud)

然后你可以自由地:

git config --global --add user.name <whatever>
Run Code Online (Sandbox Code Playgroud)

  • 我认为这是最好的答案。由于已经通过命令行进行了配置,我认为反向操作应该通过命令行来完成。否则在配置文件中进行所有配置。 (5认同)

Cru*_*der 10

git config --global --unset-all user.name
Run Code Online (Sandbox Code Playgroud)

或者您可以像这样更改用户名:

git config --global --replace-all user.name "New User Name"
Run Code Online (Sandbox Code Playgroud)

  • [user25327](http://askubuntu.com/users/150154/user25327) 的问题基本上已经提供了这个答案。我认为添加 `--replace-all` 选项应该是一个注释。 (11认同)

小智 6

git config --global -e
Run Code Online (Sandbox Code Playgroud)

此命令将打开您所期望的 GNU nano 编辑器。