I am trying to add an extra remote to an existing git project so I can push code to a secondary bitbucket repository using the git remote add user2 git@bitbucket.org:... , but I am getting the following error:
error: could not lock config file .git/config: Permission denied
It is an old project so I am not sure how it was originally setup, but it does seem like it may have been installed as root.
I tried checking the file permissions for .git and .git/config and I can see it belongs to www-data. My current user is part of the www-data group, but I still get the same error.
I also checked for .git/config.lock file just in case it was blocking but there isn't one.
I am not a fan of using sudo with .git, so I am wondering if someone can give me some best practice advice on how deal with this