I am having a strange issue that I can\'t seem to resolve. Here is what happend:
I had some log files in a github repository that I didn\'t want there. I found this
Please first give the permissions from root
account like below
chmod -R 777 foldername
after that run the commit command
I've tried fixing the ownership for Git, but it still doesn't work.
But, I've managed to fix it by creating the local branch with a different name and delete it.
Then, I check out the very same branch name again and it works.
I can't checkout `staging/rc'.
So, I checkout using staging
instead that the remote is pointing to `staging/rc'.
And, I delete it and checkout again. But, this time I use staging/rc
as my local branch name.
It works and I've no idea why.
This looks like you ran git as root locally, thus changing ownership on some of the files tracking the location of the origin
branch.
Fix the file ownership, and you should be fine:
# run this from the root of the git working tree
sudo chown -R "${USER:-$(id -un)}" .
This will change all your .git files and directories recursively (from root to 1000)and give you a full listing of all the changes made in the terminal.
sudo chown -Rc $UID .git/
In my case I created the files with root permission locally and tried to push the code to remote with local permissions. So I ran this command
$find . -user root
to find out what all files have "root" as owner. And then I changed owner for all the files that are under root to local using following command
$sudo chown parineethat `find . -user root`
Then I was able to push my code from local to remote.
Let's concentrate on what it's complaining about exactly:
Permission denied error: Cannot update the ref 'refs/remotes/origin/master'.
Before doing recursive mod/ownership changes, traverse your way to that file and fix any permissions that are incorrect.
I think I caused this issue by creating a branch while I was root and then trying to mess with that branch as my user.