Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gitconfig: Permission denied

Tags:

git

bash

I wanted to edit my .gitconfig file to change the default editor.

I typed $HOME/.gitconfig to set the correct directory and got

-bash: /Users/Myself/.gitconfig: Permission denied.

Why does it happen and what does it mean? How do I get past it?

(OS X Yosemite 10.10.4)

like image 374
U r s u s Avatar asked Aug 20 '15 15:08

U r s u s


People also ask

How do I access Gitconfig file?

The system level configuration file lives in a gitconfig file off the system root path. $(prefix)/etc/gitconfig on unix systems. On windows this file can be found at C:\Documents and Settings\All Users\Application Data\Git\config on Windows XP, and in C:\ProgramData\Git\config on Windows Vista and newer.

What is ~/ Gitconfig?

The . git/config file in each repository is used to store the configuration for that repository, and $HOME/. gitconfig is used to store a per-user configuration as fallback values for the . git/config file. The file /etc/gitconfig can be used to store a system-wide default configuration.

Why do I get permission denied in git bash?

If you get the error "Permission denied", it is also possible that git doesn't have permission to create the project folder locally. Check permissions for the directory where you're attempting to check out the project, and make sure you have write access.

Why is there no Gitconfig file?

Files like gitconfig and . gitconfig are only created when they're first used. If nobody has used the Git global scope to add a remote tracking branch, or nobody's updated the system scope to set the default Git editor to Notepad++, then the gitconfig and . gitconfig files may very well not exist in the first place.


1 Answers

Just use git command :

git config --global core.editor your-favorite-editor

--global instructs git to change your global config (effectively stored in $HOME/.gitconfig), adding the following line in the [core] section :

editor=your-favorite-editor

You can add it by hand; but for that, as said by others, you mustn't try to execute $HOME/.gitconfig, but you have to open it (with a text editor)

like image 193
Pierre-Olivier Vares Avatar answered Sep 20 '22 20:09

Pierre-Olivier Vares