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?
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.
Idealy a vi editor opens up by default if no editor is configured by the user.
- Go into insert mode by hitting
i
key, you should see -- INSERT -- displayed at the bottom of the screen- Make changes to the contents
- Once done, you need to save your changes and exit the editor. For this go into command mode by hitting
Esc
key; you should see the -- INSERT -- word has been cleared. Now type:wq
(stands for write and quit) and hit return key(Enter
key). Your config changes ahve been saved.- To verify you changes type
git config --list
orgit config --list --global
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
.
To find your $HOME, you can use below commands:
- Git Bash :
echo ~
orecho $HOME
- Command Prompt :
echo %USERPROFILE%
- Powershell :
echo $HOME
orecho $env:USERPROFILE
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"
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With