Git error: Unable to append to .git/logs/refs/remotes/origin/master: Permission denied

后端 未结 6 777
野性不改
野性不改 2020-12-22 20:28

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

相关标签:
6条回答
  • 2020-12-22 20:57

    Please first give the permissions from root account like below

    chmod -R 777 foldername
    

    after that run the commit command

    0 讨论(0)
  • 2020-12-22 21:04

    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.

    TLDR;

    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.

    0 讨论(0)
  • 2020-12-22 21:06

    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)}" .
    
    0 讨论(0)
  • 2020-12-22 21:18

    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/

    0 讨论(0)
  • 2020-12-22 21:19

    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.

    0 讨论(0)
  • 2020-12-22 21:21

    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.

    0 讨论(0)
提交回复
热议问题