question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GitHub Desktop gets confused on file permissions (x-bit) in WSL

See original GitHub issue

Describe the bug

GitHub Desktop mistakenly marks files which have the x-bit set (mode 0755 on MacOS and Linux) as changed when the checked out repo is on a WSL “share”.

Version & OS

GitHub Desktop 2.4.0, Windows 10 Pro, WSL 2 (Windows preview “slow” channel)

Steps to reproduce the behavior

  1. Open WSL 2
  2. go to a directory on a non-Windows location, e.g. your WSL home directory, not/mnt/c/Users/xyz”.
  3. Do a “git clone” of any repository containing executable scripts, such as shell scripts or Python programs.
  4. Ensure the files have the 0755 mode, aka “rwxr-xr-x” and that this is the mode of the file on GitHub in the rep. Use “git ls-files -s” to verify.
  5. Open GitHub Desktop, and add the repo as a local repo. It will be under “\\wsl$\home\<user>”.
  6. The error: GitHub Desktop will show all scripts as “Changed files”, even though nothing was actually changed. Running “git status” on the WSL commandline will show that actually nothing has changed.

Expected behavior

GitHub Desktop should show that nothing has actually changed.

Actual behavior

GitHub Desktop shows files as changed and wants them to be checked in.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:13
  • Comments:18 (1 by maintainers)

github_iconTop GitHub Comments

36reactions
Adrianilloocommented, Nov 27, 2020

This is what I did to solve this.

  • On Windows, using Git Bash for instance: git config --global core.fileMode false
  • On WSL terminal: git config --global core.fileMode true. Also, in case you didn’t have this setting when cloning repositories on WSL, you need to disable explicitly it per repository: git config --local --unset core.fileMode. According to the docs:

A repository, however, may be on a filesystem that handles the filemode correctly, and this variable is set to true when created, but later may be made accessible from another environment that loses the filemode (e.g. exporting ext4 via CIFS mount, visiting a Cygwin created repository with Git for Windows or Eclipse). In such a case it may be necessary to set this variable to false. See git-update-index[1].

The default is true (when core.filemode is not specified in the config file).`

After this, I no longer see changes caused by filemode changes done in WSL at GitHub Desktop. Note the “false” changes are also reported when running a simple git diff on Windows Git, so I don’t think this is really a Desktop bug.

8reactions
bert-lavermancommented, Apr 16, 2020

@outofambit This was a learning trajectory for me too. I found out that the “\\wsl$\<distro-name>” prefix will give you a pseudo-SMB share of the WSL2 filesystem, with all the consequences of such shares: File protection bits are not propagated properly, so if you run Windows-git on it, you should prevent trouble and disable the filemode bits.

That said, if you could actually use the “wsl” prefix and run Linux Git on the actual underlying filesystem. So, if GitHub Desktop on Windows wants to properly support WSL(2), you should replace the running of Windows Git with Git-for-Linux using the WSL prefix. So the “Add repository” dialog must allow the user to select “WSL filesystem”, with a drop-down of the Distros. Then you know you can access the files directly using “\\wsl$\<distro-name>” and adjust all runs of CLI Git.

I just tested, and the following worked:

C:\Users\user> wsl -d Ubuntu-18.04 -u user cd /home/user/dev ; ls -l
total 8
drwxr-xr-x 27 user user 4096 Apr 15 15:08 JavaDev
drwxr-xr-x  3 user user 4096 Apr 14 13:32 Support

C:\Users\user>

Or, more appropriately:

C:\Users\user>wsl -d Ubuntu-18.04 -u user cd /home/user/dev/JavaDev/running-axon-server ; git status
On branch master
Your branch is up to date with 'origin/master'.

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        renamed:    2-docker/3-docker-compose-se/docker-compose-win.yml -> 2-docker/3-docker-compose-se/docker-compose-unnamed.yml

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        2-docker/3-docker-compose-se/README.md


C:\Users\user>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Make GitHub Desktop work from WSL on Linux repositories
When I add Linux repositories to GitHub, it recognizes them, but it gets confused with file names and line endings between Linux and...
Read more >
Unable to change file permissions on Ubuntu Bash for ...
Now you are all set; changing permissions of a file in Windows from /mnt/c/ will be reflected, and mounted, correctly within WSL on...
Read more >
How do I change file permissions for a new file committed onto ...
I added a new shell script to my repo, which I committed and pushed onto my app via Github Desktop, which is on...
Read more >
Fix Windows Subsystem for Linux (WSL) File Permissions
Windows 10 is my daily driver at home so I need a way to use some Linux command-line utilities (e.g. git) without having...
Read more >
GitHub Desktop now shows pull request check run statuses
GitHub Enterprise Cloud users can now configure two new permissions when managing custom repository roles: View secret scanning results; Dismiss ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found