How to Exclude File Permission Changes from Git Tracking
To prevent Git from tracking changes in file permissions, you can modify Git’s configuration settings as follows:
Firstly, for your local repository, you can stop tracking file mode changes by executing this command in your project directory:
git config core.fileMode false
By doing this, you set the core.fileMode
property to false
, instructing Git to ignore file mode changes in your current repository.
Sometimes, you might want to run a command without permanently changing your configuration. For such cases, you can use the -c
flag with any Git command to temporarily ignore file mode changes. For instance, if you wish to see a diff without file mode changes:
git -c core.fileMode=false diff
This will output the diff for your files without including any changes to the file permissions.
If you’re like me and prefer to have Git ignore file mode changes across all your repositories, you can adjust the global Git configuration with the --global
flag:
git config --global core.fileMode false
This command alters the global Git configuration for your user account, making file mode changes invisible to Git in every repository you work with.
Git documentation: git config