Analysis and Solution for Git File Permission Mode Changes

Nov 21, 2025 · Programming · 12 views · 7.8

Keywords: Git file permissions | core.filemode configuration | cross-platform development

Abstract: This article provides an in-depth analysis of the 'old mode 100755 new mode 100644' file permission change issue in Git, explaining the meaning of Unix file permission modes and their manifestation in Git. Through the configuration of the core parameter core.filemode, it offers a complete solution to help developers effectively manage file permission differences in cross-platform development. The article combines specific examples and configuration methods to provide practical technical guidance for Git users.

Problem Phenomenon and Background Analysis

In the usage of the Git version control system, developers often encounter a specific situation: numerous files in the working copy appear in the unstaged changes area without any content modifications. When viewing the differences of these files using Git GUI tools, the displayed information typically shows:

old mode 100755
new mode 100644

This phenomenon is particularly common in cross-platform development environments, especially during code collaboration between Windows systems and Unix/Linux systems. From a technical perspective, this is not a defect of the Git system but rather results from differences in file system permission handling mechanisms across different operating systems.

Technical Analysis of File Permission Modes

In Unix/Linux systems, file permissions are represented using a three-digit octal notation, where each digit corresponds to different permission combinations:

100755 = rwxr-xr-x
100644 = rw-r--r--

Here, the first digit '1' indicates the file type (regular file), and the subsequent three digits represent permissions for the file owner, group, and other users, respectively. The permission number '755' indicates that the file has executable permissions, while '644' means the file has only read and write permissions. This permission difference is typically not strictly distinguished in Windows systems but is recognized as valid file changes in Git's cross-platform collaboration.

Core Solution: core.filemode Configuration

Git provides the core.filemode configuration parameter to specifically handle the detection of file permission mode changes. This parameter controls whether Git tracks changes in file permissions. When set to false, Git will ignore changes in file permissions and focus only on actual modifications to file content.

The configuration method is as follows:

git config core.filemode false

This configuration can be set either globally or locally within a repository. Global configuration affects all Git repositories, while local configuration applies only to the current repository. It is recommended to set this parameter to false in cross-platform development environments to avoid interference from unnecessary permission changes.

Practical Application Scenarios and Best Practices

When using Git on Windows systems, due to limited support for Unix permissions in the NTFS file system, false reports of permission mode changes frequently occur. Especially when pulling code from Linux servers to local Windows environments, the executable permissions of files may be lost, causing Git to misinterpret this as file changes.

Below is a complete configuration example:

# Check current core.filemode setting
git config --get core.filemode

# Set to false to ignore file permission changes
git config core.filemode false

# Verify if the setting has taken effect
git config --get core.filemode

After the configuration is complete, the previous permission change records will disappear from the unstaged changes area, allowing developers to focus on genuine code content changes. This solution is effective not only in Git GUI tools but also in command-line environments.

Technical Details and Considerations

It is important to note that the core.filemode setting only affects Git's tracking of file permission changes and does not alter the actual permissions of files on disk. In pure Unix/Linux environments, if tracking file permission changes is necessary, the default value of this parameter should remain true.

Additionally, this setting does not affect permission information already committed to the repository. If there are existing commit records of permission changes in the repository, these records will remain unchanged. New permission changes will only be ignored after setting core.filemode false.

For team collaboration projects, it is advisable to clearly specify the file permission handling strategy in project documentation to ensure consistent environment configuration among all developers and avoid collaboration issues caused by permission differences.

Copyright Notice: All rights in this article are reserved by the operators of DevGex. Reasonable sharing and citation are welcome; any reproduction, excerpting, or re-publication without prior permission is prohibited.