【问题标题】:"Permission denied" error when trying to switch branches尝试切换分支时出现“权限被拒绝”错误
【发布时间】:2019-04-28 05:05:58
【问题描述】:

我正在尝试使用git reset --hard,但出现此错误:

fatal: cannot create directory at '[path]/img/products': Permission denied

我没有更改权限,之前一切正常。然后我尝试git checkout [branch name],我得到了这个:

error: cannot stat '[path]/img/products': Permission denied
error: cannot stat '[path]/img/products': Permission denied
error: cannot stat '[path]/img/products': Permission denied
error: cannot stat '[path]/img/products': Permission denied
error: cannot stat '[path]/img/products': Permission denied
error: cannot stat '[path]/img/products': Permission denied
error: cannot stat '[path]/img/products': Permission denied
error: cannot stat '[path]/img/products': Permission denied
error: cannot stat '[path]/img/products': Permission denied
error: cannot stat '[path]/img/products': Permission denied
error: cannot stat '[path]/img/products': Permission denied
error: cannot stat '[path]/img/products': Permission denied
error: cannot stat '[path]/img/products': Permission denied
error: cannot stat '[path]/img/products': Permission denied
error: Your local changes to the following files would be overwritten by checkout:
        [path]/img/products/icons.png
        [path]/img/products/buttons.png
Please commit your changes or stash them before you switch branches.
error: The following untracked working tree files would be overwritten by checkout:
        [path]/img/leftbtn.png
        [path]/img/rightbtn.png
        [path]/img/logo.png
Please move or remove them before you switch branches.
Aborting

之前一切正常,我突然开始遇到上述问题。我只是想切换分支。你有什么推荐的尝试?

【问题讨论】:

    标签: git permissions branch file-permissions git-reset


    【解决方案1】:

    很奇怪。我又试了git checkout [branch name],这次是我看到的错误:

    error: The following untracked working tree files would be overwritten by checkout:
            [path]/img/leftbtn.png
            [path]/img/rightbtn.png
            [path]/img/logo.png
    Please move or remove them before you switch branches.
    Aborting
    

    我删除了那些文件,又试了git checkout [branch name],这次可以成功切换分支了。

    【讨论】:

      猜你喜欢
      • 2012-06-09
      • 2019-01-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-19
      • 1970-01-01
      • 2015-11-09
      相关资源
      最近更新 更多