git rebase:“error:can not stat'file':Permission denied” [英] git rebase: "error: cannot stat 'file': Permission denied"
问题描述
我使用git,并做了一个小的提交,然后是一个大的提交。我决定在推送它们之前使用 git rebase
压缩两个提交。 (我从来没有这样做过。)
所以我做了:
git rebase -i HEAD〜2
这给了我我的编辑,在那里我选择了先前的提交并压缩后面的提交。当我保存时,git说:
error:can not stat' filename ':Permission denied
无法将 sha1应用于以后的提交 ... 该提交的初始文本行
现在:
git log
。
git status
告诉我我目前没有任何分支。
发生了什么!如何解决它?
我只在Windows上看过这个错误,它似乎是什么在试图应用补丁时阻止git修改文件。
当应用程序实际上不需要时,Windows倾向于给予进程独占访问权限,在过去,病毒检查人员一直是怀疑的来源,但我从来没有证实这一点。
可能最简单的事情就是放弃并重试,希望它不会在下次发生。 git rebase --abort
您可以尝试使用 git apply
并了解git之前实际尝试执行的操作做一个 git rebase --continue
但是诚实地说,我不会推荐这个。大多数时候,我看到这种情况已经有一个比偶然发生的事情更好的机会,偶然错过或搞砸了。
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 never done this before.)
So I did:
git rebase -i HEAD~2
This gave me my editor, where I chose to pick the earlier commit and squash the later one. When I saved, git said:
error: cannot stat 'filename': Permission denied
Could not apply sha1 for later commit... initial line of text for that commit
Now:
- Neither commit appears when I do
git log
. git status
tells me I'm "Not currently on any branch."- One file is listed as modified and in the index, and two files are listed as untracked. My first commit had just one file (I think), and my second commit had a good dozen.
What happened!? How do I fix it?
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.
这篇关于git rebase:“error:can not stat'file':Permission denied”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!