I have a project in which I have to change the mode of files with chmod
to 777 while developing, but which should not change in the main repo.
Git picks up on chmod -R 777 .
and marks all files as changed. Is there a way to make Git ignore mode changes that have been made to files?
If you want to set this option for all of your repos, use the
--global
option.If this does not work you are probably using a newer version of git so try the
--add
option.If you run it without the --global option and your working directory is not a repo, you'll get
Simple solution:
Hit this Simple commend in project Folder(it won`t remove your original changes) ...it will only remove changes what had been done while you changed project folder permission
commend is below:
git config core.fileMode false
Why this all unnecessary file get modified: because you have changed the project folder permissions with commend sudo chmod -R 777 ./yourProjectFolder
when will you check changes what not you did? you found like below while using git diff filename
Try:
From git-config(1):
The
-c
flag can be used to set this option for one-off commands:And the
--global
flag will make it be the default behavior for the logged in user.Warning
core.fileMode
is not the best practice and should be used carefully. This setting only covers the executable bit of mode and never the read/write bits. In many cases you think you need this setting because you did something likechmod -R 777
, making all your files executable. But in most projects most files don't need and should not be executable for security reasons.The proper way to solve this kind of situation is to handle folder and file permission separately, with something like:
If you do that, you'll never need to use
core.fileMode
, except in very rare environment.Adding to Greg Hewgill answer (of using
core.fileMode
config variable):You can use
--chmod=(-|+)x
option of git update-index (low-level version of "git add") to change execute permissions in the index, from where it would be picked up if you use "git commit" (and not "git commit -a").This works for me:
or reverse, depending on your operating system