How to make Git ignore file permission (chmod) changes

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 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.

Total
0
Shares
Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post
how-do-liquidity-pools-work?-(like-uniswap-or-balancer)

How Do Liquidity Pools Work? (Like UniSwap or Balancer)

Next Post
os-desafios-de-ser-devrel

Os desafios de ser DevRel

Related Posts