Git changes stuck on Windows

Windows and vscode. Have not seem this on Linux (yet).

You have files that are stuck in ‘Changes’ and can’t be removed or discarded.

Show the difference of the file changes:

git diff

Show all the files that are marked as changed:

diff –git file.derp old mode 100755 new mode 100644

This permission issue be resolved in a few ways:

  1. Commit the files with the changed permissions. This is the preferred way since you will respect my authoritah the (sane) default permissions. However this may not be possible if you have a lot of incoming changes as these files cannot be stashed, and the git pull will fail. git stash save --include-untracked saving_files will also fail. Doing this will also potentially mess up your other branches in the same way.

  2. Set the config for the current repository only (temporarily):

git config core.filemode false

Fetch and pull again:

git fetch -p && git pull

You will most likely see a bunch of permission changes, but should be up to date now.

Reset that nice sane default again:

git config core.filemode true

  1. Remove the local git directory and start over by cloning the repository from origin again. You will still have to manage the permissions, but at least it will be manageable on your localhost and only the file permissions that needs to be changed are different.
rf --force local_git_repo_dir
git clone git@gitlab.com:lamerschool/lamerschool.com.git

What is the reason for this?

UNIX file permissions. The old mode included the executable flag (+x) but the new mode does not. This is a good thing. You probably do not want your incoming files to have the safety off. :)

Check where the core.filemode setting is coming from, your ~./.gitconfig or the repository ./git/config:

git config --show-origin --show-scope --get-all core.filemode

List all files that are modified:

git ls-files -m

List all files that are staged:

git ls-files --stage


Make sure to always keep your Operating System(s) and all of the software that you are using up to date.

Feedback on our content or did you find a bug somewhere?

Send us an email to feedback at this domain.

kthxbai