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.
More Tips and Tricks for Git
- How to make Git forget a tracked file now in .gitignore
- Git Stash - Everything about stashing changes in git
- How to amend and update a git commit
- Resolving Git Merge Conflicts
- How to Auto Compress Your CSS and JS with Git Hooks
- Git blame - How to find out who modified a line with Git
- Git Merge: Merging Changes from other Branches
- How to add a Blank Directory to your Git Repository
- A Step by Step Guide to Git Branches
- The Complete Beginners Guide to Getting Started with Git