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

后端 未结 30 2299
野趣味
野趣味 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 05:14

    If you have the Meld merge tool open, close that. It blocks the file overwriting.

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

    When I see this on my machine, it's worse than just a "some process has the file open". The actual ownership of the file gets jacked up to the point where I (running as administrator) can only access it after rebooting.

    Nearest I can tell, IIS is part of the problem. If I switch between two major branches that require a lot of files to modify, git will delete a file or directory (usually DLLs) while IIS is trying to do something or another with it. At this point, the IIS process automatically overwrites the file on disk with a version that's locked and appears to be owned by nobody.

    Stopping IIS at this point doesn't do it. Best I've found out to do is to reboot, and remember to stop IIS before changing across major branches in the future.

    I know that doesn't really answer the question, but might be helpful to others.

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

    I've only ever seen this error on Windows and what it seems to mean is that something blocked git from modifying a file at the moment when it tried to a apply a patch.

    Windows tends to give processes exclusive access to files when it shouldn't really be necessary, in the past virus checkers have been one source of suspicion but I've never proved this conclusively.

    Probably the easiest thing to do is to abort and try again, hoping that it doesn't happen the next time.

    git rebase --abort
    

    You can attempt to use git apply and knowledge of what commit git was actually trying to do before doing a git rebase --continue but in all honesty I wouldn't recommend this. Most of the times I've seen this tried there's been a better than evens chance that something gets accidentally missed or messed up.

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

    I exited from my text editor that was accessing the project directories, then tried merging to the master branch and it worked.

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

    I have just had this under Win 7.

    $ git stash pop error: cannot stat 'parentFolder/subfolder': Permission denied error: cannot stat 'parentFolder/subfolder': Permission denied

    Diagnosis:

    1>I went to the subfolder and it's there and I couldn't delete it !

    2>Use "process explorer" -> Find -> Find handles and Dlls -> put the "subfolder" name there and search.

    Result: It turns out it's XMLSpy has opened one of the xml there, close XML Spy and try stash pop again, it's working now.

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

    Happened to me when in windows, when using photoshop: When I saved an image and then switched to a branch (leaving photoshop with the image opened) i got the git error. Close the image in photoshop and retry

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