git rebase: “error: cannot stat 'file': Permission denied”

后端 未结 30 2298
野趣味
野趣味 2020-12-02 04:56

I\'m using git, and made a small commit followed by a large one. I decided to use git rebase to squash the two commits together before pushing them. (I\'ve ne

相关标签:
30条回答
  • 2020-12-02 04:58

    Same issue on Windows 10 64 Bit, running Git Bash version 2.9.0.windows1 Using Atom as my editor.

    This worked for me: I added the Git software folder (for me, this was C:\Program Files\Git) to the exclusions for Windows Defender.

    After the exclusion was added, git checkout 'file' worked fine.

    0 讨论(0)
  • 2020-12-02 04:59

    Just close your IDE (VISUAL STUDIO/ATOM etc). It might work

    0 讨论(0)
  • 2020-12-02 04:59

    This error can also be caused by the fact that files are still "locked" because of prior git actions. It has to do with how the Windows filesystem layer works. I once read a nice explanation on this, but I can't remember where.

    In that case however, since it is basically a race condition, all you have to do is continue your interrupted rebase process. Unfortunately this happens to me all the time, so I wrote this little dangerous helper to keep my rebases going:

    #!/bin/sh
    
    set -e
    
    git checkout .
    git clean -df
    git rebase --continue
    

    If you want to be extra sure, you can use git rebase --edit-todo to check if the next commit to be applied is really the one that failed to be applied before. Use git clean -dn to make sure you do not delete any important files.

    0 讨论(0)
  • 2020-12-02 05:00

    Try closing any programs that have the folder open, such as editors, explorer windows, command prompts, and FTP programs. This always fixes the issue for me on Windows.

    0 讨论(0)
  • 2020-12-02 05:02

    If you're running webpack shut it down. Shut down your IDE as well. Should work fine after doing those things.

    0 讨论(0)
  • 2020-12-02 05:02

    I've just had this problem. The thing is - if you had opened file, that was removed\replaced after rebase (you had a branch which doesn't have a this file anymore), the git-system corrupts. So i closed all opened files and then tryied to checkout on some other branch

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