error: could not lock config file filepath/../.git/config :permission denied
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
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.
git init
This worked for me in the case where .git
folder is deleted.