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
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
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 Git
- Git blame - How to find out who modified a line with Git
- How to make Git forget a tracked file now in .gitignore
- How to Auto Compress Your CSS and JS with Git Hooks
- Using Git to see recent changes in specified a time period
- How to amend and update a git commit
- Setting upstream with Git
- How to make Git ignore file permission (chmod) changes
- How to add a Blank Directory to your Git Repository
- Git Stash - Everything about stashing changes in git
- How to force overwrite local changes with 'git pull'