'How can I edit the .git / config file from the git terminal?
I am trying to modify the config file from the git terminal, for this, inside the repository, I have launched the command git global --edit
.
An editor opens within the same terminal, my problem is, how can I save the changes and exit the editor?? Every time I make a change the editor crashes and I have to start over.
Is there a way to do it more easily outside of the terminal?
Solution 1:[1]
I have launched the command git global --edit
Not sure how and why that works for you. That should not have worked in the first place. To edit the config globally in editor, you should use below command :
git config --global --edit
This should open a text editor, make your changes ,save and exit the editor. That should work.
If you don't want to use the command and still want to be able to edit the git config, then locate the .gitconfig
file in your home directory $HOME/.gitconfig
.
NOTE: You can also change the default editor that git commands open up by executing below command in your git bash :
git config --global core.editor "<editor-name> --wait"
Replace <editor-name>
with the editor of your choice which is currently installed on your system. For VS code , the command would be :
git config --global core.editor "code --wait"
Solution 2:[2]
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
Note: Windows system, except commands may be different
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Ethan |