DEV Community 👩‍💻👨‍💻

Cover image for How to make Git ignore file permission (chmod) changes
Johnny Simpson
Johnny Simpson

Posted on • Originally published at

How to make Git ignore file permission (chmod) changes

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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.

Top comments (0)

Let's team up together 🤝

We're Hiring

We're hiring for a Senior Full Stack Engineer to join the DEV team. Want the deets? Head here to learn more about who we're looking for.