error: could not lock config file filepath/../.git/config :permission denied

Bhishan Poudel picture Bhishan Poudel · Aug 19, 2015 · Viewed 87.3k times · Source

i created a folder called "try" in the path /home/bhishan/Copy/try then inside that folder i gave some commands:

my commands are follwing:

curl -s -O \
http://github-media-downloads.s3.amazonaws.com/osx/git-credential-osxkeychain

chmod u+x git-credential-osxkeychain

sudo mv git-credential-osxkeychain `dirname \`which git\``

git config --global credential.helper osxkeychain

git init

git remote add origin https:

git remote add origin https:

git push origin master

==============================

it worked fine but, when i try to delete try folder i cannot delete the folder. i also can not give command:

git init

inside the try folder ( i have a .git folder there)

=====================================================

my command line and error report is this:

bhishan@bhishan-HP-Pavilion-dv6-Notebook-PC:~/Copy/try$ git init
error: could not lock config file /home/bhishan/Copy/try/.git/config: Permission denied

now, my question is how can i delete the folder called "try" ?

Answer

Aaron D picture Aaron D · Aug 19, 2015

These kinds of problems occur when you use sudo to run commands with side effects such as file creation.

It's quite common to find files and directories in your home directory that are owned by root. In this case it seems your .git/config file is owned by root and thus gives you the permissions error when you try to lock it.

sudo chown bhishan -R .git from the ~/Copy/try directory should fix the permissions issue.