Fix: error: could not lock config file /etc/gitconfig: Permission denied


error- could not lock config file :etc:gitconfig- Permission denied
myrepo$ git config --system core.editor "nano -w"

error: could not lock config file /etc/gitconfig: Permission denied

If you are trying to add or edit a system configuration file you will get a Permission denied error because you need special privileges to access it.

Fix:

For the above example, it is better to set the core.editor at the user level using the --global configuration.

If you really want to set a property at the system level make use of sudo

sudo git config --system core.editor "nano -w"

Again you should have special privileges to do so, if not you will get sudoers error.

[sudo] password for user1: 
user1 is not in the sudoers file.  This incident will be reported.

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org



















Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap