How to make Git ignore file permission (chmod) changes

📣 Sponsor

Have you ever made some changes in git, and then changed the files permissions too, only to realise you only want to publish the changes to the files, and not the file permissions? Or maybe you’ve updated the file permissions on a bunch of files, which you do not want to publish to your repository. This can happen if you update a file’s chmod or file permissions.

By default, if you do a git push or a git commit on these files, the file permissions will be uploaded too. Files which have restricted file permissions, will still have them when they are pulled from the repo.

That can be fine if you want a file’s permissions to be published, but sometimes you only want to commit the content, and not the changes in file permission. If you want to ignore file permissions, then you can run the following command in git:

git config core.fileMode false

This will update the the git configuration for this repository to completely ignore file permission changes when doing a commit and push. Note, you can only switch this on or off for all files. To change it back to the default setting, so that file permissions will be committed and pushed to your repositories, you can run the command again with a value of true:

git config core.fileMode true

Note: be careful when using this. Although useful, make sure you set it back to true, so that you don’t affect the future development of your repository in a negative way.

Last Updated 1662328808586

More Tips and Tricks for Git

Subscribe for Weekly Dev Tips

Subscribe to our weekly newsletter, to stay up to date with our latest web development and software engineering posts via email. You can opt out at any time.

Not a valid email