git rebase:“错误:无法统计‘文件‘:权限被拒绝”

本文翻译自:git rebase: “error: cannot stat 'file': Permission denied”

I'm using git, and made a small commit followed by a large one. 我正在使用git,并做了一个小提交,然后是一个大提交。 I decided to use git rebase to squash the two commits together before pushing them. 在决定推送它们之前,我决定使用git rebase将两个提交压缩在一起。 (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: 当我救了,git说:

error: cannot stat ' filename ': Permission denied 错误:无法统计' 文件名 ':权限被拒绝

Could not apply sha1 for later commit ... initial line of text for that commit 无法将sha1应用于以后的提交 ... 该提交的初始文本行

Now: 现在:

  • Neither commit appears when I do git log . 当我执行git log时,都不会出现提交。
  • git status tells me I'm "Not currently on any branch." git status告诉我,我“目前不在任何分支上。”
  • 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? 我如何解决它?


#1楼

参考:https://stackoom.com/question/P3IV/git-rebase-错误-无法统计-文件-权限被拒绝


#2楼

我们通过右键单击Program Files中的sh.exe并在Security选项卡中设置“以管理员身份运行”来解决权限问题。


#3楼

My encounter with this problem was caused by my editor, Intellij. 我遇到这个问题是由我的编辑Intellij引起的。 As part of its internal version controls, it had gone through and locked all hidden git files. 作为其内部版本控件的一部分,它已经完成并锁定了所有隐藏的git文件。 (For various reasons, I was not using the git plugin that comes with Intellij...) (由于各种原因,我没有使用Intellij附带的git插件......)

So I opened a normal dos window as Administrator, changed to the directory, and executed 所以我以管理员身份打开了一个正常的dos窗口,更改为目录并执行

attrib -R /S

That removed the lock on the files and everything worked after that and I could sync my changes using the GitHub windows client. 这删除了文件上的锁定,之后一切正常,我可以使用GitHub Windows客户端同步我的更改。


#4楼

Just close your IDE (VISUAL STUDIO/ATOM etc). 只需关闭IDE(VISUAL STUDIO / ATOM等)。 It might work 它可能会奏效


#5楼

I got this error when my VS1013 was on a branch targeting 8.1 and I was trying to checkout a 8.0 branch. 当我的VS1013在8.1的分支上时,我遇到了这个错误,我试图检查8.0分支。 I needed to tab back to VS and allow it to UpdateAll. 我需要回到VS并允许它更新到UpdateAll。 Then I could checkout the 8.0 branch without error. 然后我可以没有错误地检查8.0分支。


#6楼

I agree with the above "Close Visual Studio" answers. 我同意上面的“Close Visual Studio”答案。

However, an additional step I had to do even after I'd closed Visual Studio was to manually kill the "devenv.exe" Visual Studio process in Task Explorer. 但是,额外的步骤我有我已经关闭后的Visual Studio是手工 “devenv.exe的” Visual Studio中的任务Explorer进程的事。 After I had done this I was able to again run in gitbash: 在我完成这个之后,我能够再次使用gitbash:

git pull git pull

and the "cannot stat filename " error disappeared. 并且“无法统计文件名 ”错误消失了。 It is perhaps due to a Visual Studio extension keeping the process open for longer even after closing. 这可能是由于Visual Studio扩展程序即使在关闭后也会保持打开的时间更长。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值