Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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" ?

like image 957
BhishanPoudel Avatar asked Aug 19 '15 00:08

BhishanPoudel


2 Answers

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.

like image 148
Aaron D Avatar answered Sep 20 '22 16:09

Aaron D


I'm adding answer to this question because I ended up here while trying to resolve quite almost the same issue.

Had that issue also in git. But for what I know, it's not just my git that is having the permission denied issue but the whole application folder. and even if I try to use git in another project, it works fine.

To add up with @Aaron D's answer, you can use $(whoami) instead of bhishan. Just like this:

$ sudo chown $(whoami) ~/Copy/try 

https://stackoverflow.com/a/52315546/4477550reference

P.S. To answer your question:

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

You can run this command:

$ sudo rm -rf /home/bhishan/Copy/try 
like image 22
Vince Banzon Avatar answered Sep 20 '22 16:09

Vince Banzon