1

I was working with git bash on Windows. 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. Git told me that I didn't have permissions to get a bunch of files and refused to checkout the branch.

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. Using the former, I see that the folder containing the files has permissions of 040000 on the branch I want to switch back to. 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. 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.

faiuwle
  • 359
  • 1
  • 3
  • 10

2 Answers2

0

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. 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). 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. I'm not sure what happened here and would still like an explanation if anyone has one.

faiuwle
  • 359
  • 1
  • 3
  • 10
0

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.

That could explain the original error message, without involving the actual (chmod) permission.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Would something like having Windows Explorer open with the directory tree expanded do that? I noticed it had the directory tree expanded after the fact (and that's why I was able to delete the folder from there). I would have thought that would have prevented me from checking out master, though, (where these folders did not exist) but that worked fine. – faiuwle Jan 05 '19 at 00:37
  • @faiuwle That is possible, yes. The point being, I doubt it was a permission issue. – VonC Jan 05 '19 at 00:40
  • Can you explain how to check permissions on Windows for real? Obviously the way I did it wasn't very informative. – faiuwle Jan 06 '19 at 05:51
  • @faiuwle Git on Windows only records 644/755 (https://stackoverflow.com/a/40979867/6309). The read/write aspect is tied to the Windows OS and is ignored by Git. The execution part can be recorded (https://stackoverflow.com/a/51527330/6309). – VonC Jan 06 '19 at 15:20