简体   繁体   English

如何在Windows上的git中使文件可读写?

[英]How do I make files readable and writable in git on Windows?

I was working with git bash on Windows. 我在Windows上使用git bash。 I edited some files, committed them and pushed to a branch, and then I switched back to master to pull it and then tried to switch back to my branch to merge master into it. 我编辑了一些文件,提交了它们,并将其推送到分支,然后切换回master进行拉动,然后尝试切换回我的分支以将master合并到其中。 Git told me that I didn't have permissions to get a bunch of files and refused to checkout the branch. Git告诉我,我没有获取一堆文件的权限,因此拒绝签出该分支。

The only thing I can find on changing file permissions in git on Windows are a bunch of posts about how to flip the executable bit, and telling me I could see the permissios using git ls-tree branch and git ls-files branch . 我在Windows上的git中更改文件权限的唯一发现是关于如何翻转可执行位的一堆帖子,并告诉我可以使用git ls-tree branchgit ls-files branch查看权限。 Using the former, I see that the folder containing the files has permissions of 040000 on the branch I want to switch back to. 使用前者,我看到包含文件的文件夹在我要切换回的分支上的权限为040000。 Obviously flipping the executable bit isn't going to make this folder read-writable. 显然,将可执行文件位翻转不会使此文件夹可写。 How do I change those permissions back? 如何更改这些权限?

Edit: After looking around, I'm confused. 编辑:环顾四周后,我很困惑。 All of the folders have the same permissions as above (040000) but I can cd into them and view the files there. 所有文件夹都具有与上述文件夹相同的权限(040000),但是我可以将其安装到其中并查看其中的文件。 The folders that are the problems are ones that were added only in the new branch. 问题所在的文件夹是仅在新分支中添加的文件夹。 I seem to have copies of them in my checked-out repo anyway, but they can't be accessed, either through git bash, or Windows Explorer. 无论如何,我似乎都已在检出的存储库中保存了它们的副本,但是无法通过git bash或Windows资源管理器对其进行访问。

Well, in this particular case I was able to solve the problem by deleting the folder containing one of the offending folders through Windows Explorer. 好了,在这种情况下,我可以通过Windows资源管理器删除包含有问题的文件夹之一的文件夹来解决问题。 After I did this, I tried to delete the other folder, but clicking on it caused Windows to tell me it did not exist anymore (rather than that I couldn't access it, which is what it had been telling me before). 完成此操作后,我尝试删除另一个文件夹,但是单击该文件夹导致Windows告诉我该文件夹不再存在(而不是我无法访问它,这是它之前告诉我的)。 These two folders were not related to each other at all. 这两个文件夹根本不相关。 Anyway, I confirmed that neither folder existed in git bash, and was then able to successfully check out the branch. 无论如何,我确认git bash中都没有该文件夹,然后能够成功检出该分支。 I'm not sure what happened here and would still like an explanation if anyone has one. 我不确定这里发生了什么,如果有人请解释一下。

It is possible a Windows process was keeping an active handle to those folders, preventing git checkout to complete successfully: the checkout should have deleted those folder when switching back to your branch. Windows进程可能会保留这些文件夹的活动句柄,从而阻止git checkout成功完成:当切换回分支时,checkout应该已经删除了那些文件夹。

That could explain the original error message, without involving the actual (chmod) permission. 这可以解释原始错误消息,而无需涉及实际的(chmod)权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM