Friday, 23 December 2022

Git and core.filemode - Issues on Windows with executable bits in Git repos

 I've seen this where you check out source in WSL2 (Linux) and a file has an executable bit set.

Then you look at it in Windows using something like SourceTree and the file that it not reporting as modified in Linux is reporting a modified in SourceTree.

The issue is the core.filemode that is set in the repo's .git/config file is determined by the Git running on the OS that did the clone - it'll be "true" for Linux, and "false" if you cloned using a Windows Git.

If you want to avoid problems, after cloning in WSL2, edit the filemode value to false and Windows Got will behave.

If you do that, in order to ass executable attributes to a file you need to use git update-index chmod +x as filesystem changes made in WSL2 won't be picked up.


No comments:

Post a Comment