Making Git Ignore File Permissions

I found a cool little trick today.  The file permissions are making git think that the file changed.  There is a simple command that tells it to ignore those changes:

git config core.filemode false

So, here’s the deal.  I have a virtual  machine that has a folder mounted from the host.  My development directory is in that folder.

When I run git on the host, the directory is clean.  No uncommitted changes:


skp@pecan:~/app/vhhb/devtools/ace$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
# (use "git push" to publish your local commits)
#
nothing to commit, working directory clean

But, when I ran git on the virtual machine in the same directory, it found a bunch of changes.  So, I looked at the differences.  Here’s one of the files from the host machine:


skp@pecan:~/app/vhhb/devtools/ace$ ll ace-uncompressed.js
-rw-rw-r-- 1 skp skp 593435 Sep 4 11:48 ace-uncompressed.js

And, here’s that same file from the virtual machine:


skp@vhhb:/var/www/devtools/ace$ ll ace-uncompressed.js
-rwxrwx--- 1 root vboxsf 593435 Sep 4 11:48 ace-uncompressed.js*

So, I ran our nifty little command on the virtual machine:

git config core.filemode false

Now, it shows a clean working directory even from the virtual machine.


skp@vhhb:/var/www/devtools/ace$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
# (use "git push" to publish your local commits)
#
nothing to commit, working directory clean

So, it’s a cool little tip I need to remember.

Resources

Stack Overflow: How do I make git ignore mode changes (chmod)?

Leave a Comment

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