tags:

views:

3809

answers:

3

I have a project in which I have to change the mode of files (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?

+48  A: 

Try:

git config core.filemode false

From git-config(1):

   core.fileMode
       If false, the executable bit differences between the index and the
       working copy are ignored; useful on broken filesystems like FAT.
       See git-update-index(1). True by default.
Greg Hewgill
Thanks a bunch Greg.
Marcus Westin
Up-vote for you and OP. Oh god that just saved me headaches-o-plenty from managing this repository.
Dmitriy Likhten
Today I couldn't recall exactly how to do this, searched Google, and found my own answer from last year as the top hit. Stack Overflow rocks.
Greg Hewgill
+7  A: 

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

Jakub Narębski
+8  A: 

undo mode change in working tree:

git diff --summary | grep --color 'mode change 100755 => 100644' | cut -d' ' -f7- | xargs -d'\n' chmod +x
git diff --summary | grep --color 'mode change 100644 => 100755' | cut -d' ' -f7- | xargs -d'\n' chmod -x
yoda
Woa! Beaufitul!
Marcus Westin
Thanks, you saved my day. :)
TNunes