我正在尝试通过git终端修改配置文件。为此,在存储库内,我启动了命令
git global --edit
。然后,一个编辑器在同一终端中打开,我的问题是,如何保存更改并退出编辑器?每次我进行更改时,编辑器都会崩溃,我必须重新开始。是否有更容易的方法在终端之外完成这个任务?git global --edit
。然后,一个编辑器在同一终端中打开,我的问题是,如何保存更改并退出编辑器?每次我进行更改时,编辑器都会崩溃,我必须重新开始。是否有更容易的方法在终端之外完成这个任务?我已经启动了命令 git global --edit
不确定这个命令对你来说是如何有效的,也不清楚为什么它会生效。实际上,它本应该无法生效。 如果你想要在编辑器中全局修改配置,应该使用以下命令:
git config --global --edit
$HOME/.gitconfig
中找到.gitconfig
文件。git config --global core.editor "<editor-name> --wait"
<editor-name>
替换为你当前系统上安装的编辑器。对于VS Code,命令将是:git config --global core.editor "code --wait"
Open Git Bash.
Enter the command below:
git config --global --edit
Press 'i' to enable edit -- i.e i
Enter or modify the user:
For example:
[User1] i.e can use any name like Personal, Business, other, etc..
name = <github username>
email = <github email>
[User2] i.e can use any name like Personal, Business, other, etc..
name = <github username>
email = <github email>
Press - esc button.
Now cursor will move at bottom.
enter :wq
and press the Enter button to exit. i.e :wq
Verify the detail by using:
git config --list
注意:除命令外,Windows系统可能有所不同
:wq
再按回车(Windows上的“Enter”键)。wq
命令可保存您所做的更改并退出程序。只需输入:q
即可退出而不保存更改。 - Asif Kamran Malick'
将其括起来,例如"'C:\Program Files\Myeditor' -multiInst -nosession"
。 - ΩmegaMangit config --global core.editor "notepad++"
(这里不需要--wait)。 - Matt