Search code examples
rubyvisual-studio-codewindows-subsystem-for-linux

VScode, WSL, Ruby, Files Being Marked as Changed on Commit


I'm working on VScode running on WSL for Ruby. Every time I go to commit, 8 files are marked as changed, but no changes are visible when I try to compare them. My brother, my boss, thinks that VScode is making changes to the permissions on these files, which concerns him.

The 8 files are:

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   bin/bundle
        modified:   bin/dev
        modified:   bin/rails
        modified:   bin/rake
        modified:   bin/rubocop
        modified:   bin/rubycritic
        modified:   bin/setup
        modified:   release-tasks.sh

I definitely do not want to change these files at all. My role is to focus on the CSS and frontend views.

The question is

A) is there a way to find out what the changes are? B) is there a way to prevent VScode from marking them as changed, or better yet, not change them?

EDIT 2309071405

In response to a comment, this is the result of git diff below. It does seem to be permissions.

fleetwoodn@DESKTOP-GSMDGGD:~/MyChange2$ git diff
diff --git a/bin/bundle b/bin/bundle
old mode 100755
new mode 100644
index b6d1327..156453a
--- a/bin/bundle
+++ b/bin/bundle
@@ -1,124 +1,124 @@
-#!/usr/bin/env ruby
-# frozen_string_literal: true
-
-#
:

Solution

  • It looks like VSCode is indeed changing the permissions on the files you mentioned. The git diff output you provided shows that the file bin/bundle has changed from mode 100755 to mode 100644. This means that the file's permissions have been changed from executable to read-only.

    You can add the following line to your .gitignore file to prevent VSCode from changing the permissions on the files you mentioned:

    bin/*
    

    Another way to prevent VSCode from changing the permissions on these files is to use the gitattributes file. The gitattributes file is a file that specifies the attributes of files, such as their permissions. You can add the following line to your gitattributes file to prevent VSCode from changing the permissions on the files you mentioned:

    * -executable
    

    Finally, you can also disable the file watcher in VSCode. The file watcher is responsible for detecting changes to files and updating the Git status. To disable the file watcher, open the VSCode settings and search for "file watcher". Then, uncheck the checkbox next to "Enable file watcher".

    Once you have taken one of these steps, VSCode should no longer change the permissions on the files you mentioned.