I’m getting this error when trying to set the global config
git config --global user.name "Your Name Here"
error: could not lock config file /root/.gitconfig: No such file or directoryEarlier it was working fine, i was able to pull & push the code easily. But suddenly I started facing this issue. What I am doing wrong?
This is not a problem with your git. It’s related to server permission issue.
So first you need to check if this .gitconfig file exist at given location or not,
sudo chmod 777 ~/.gitconfig
if it’s file persmission issue, it will get fixed after this command.
if you are getting file not found again, then this file doest not exist anymore. So let’s create this file.
sudo nano ~/.gitconfig
save this file. If all it’s got created means your problem solved.
If stil you are getting same error that means root folder itself not having write permission or does not exist.
So try giving write permission to root
sudo chmod 777 -R ~/
if it went good, then you need to just create .gitconfig file inside it with command given above and done.
If it’s showing /root/ doest not exist, that means folder is missing.
so let’s create this folder followed by create .gitconfig file
sudo mkdir ~/ sudo nano ~/.gitconfig
your problem is solved now. 🙂