Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git is not ignoring file mode changes (chmod), why?

Tags:

git

ignore

Before start I should say I already looked this post and this one as well but for some reason the solutions provided there aren't working for me. My repository is under ~/sources so every command was run from that path. This is what I have done:

Change the filemode to false:

$ git config --global core.filemode false

Check global configuration:

$ git config --list
...
core.filemode=false
core.repositoryformatversion=0
core.bare=false
core.logallrefupdates=true
...

Reinitialize the repository:

$ git init
Reinitialized existing Git repository in /home/rperez/sources/.git/

Check what needs to be added|committed:

$ git status

And I get a list having all the files from the repository.

I am using:

$ git --version
git version 2.9.3

UPDATE: added git diff for two different files

$ git status
...
    modified:   testing/test-valid-swasset-update.php
...
Untracked files:
  (use "git add <file>..." to include in what will be committed)

    library/mpdf60/ttfontdata/dejavusanscondensedI.GDEFdata.php
...

git diff output from the files above:

$ git diff testing/test-valid-swasset-update.php
diff --git a/testing/test-valid-swasset-update.php b/testing/test-valid-swasset-update.php
old mode 100755
new mode 100644

What I am missing here?

like image 594
ReynierPM Avatar asked Dec 13 '16 14:12

ReynierPM


People also ask

Why is git not ignoring a file?

Git can only ignore files that are untracked - files that haven't been committed to the repository, yet. That's why, when you create a new repository, you should also create a . gitignore file with all the file patterns you want to ignore.

How do I ask git to ignore a file?

If you want to ignore a file that you've committed in the past, you'll need to delete the file from your repository and then add a . gitignore rule for it. Using the --cached option with git rm means that the file will be deleted from your repository, but will remain in your working directory as an ignored file.

How do I ignore changes in git?

Use Git update-index to ignore changes Or, you can temporarily stop tracking a file and have Git ignore changes to the file by using the git update-index command with the assume-unchanged flag.


2 Answers

Local config overrides global config settings

The diff output in the question indicates that the local git config has filemode set to true. This is probably expected behavior since the default config created for a repo defines this:

-> git init
Initialized empty Git repository in /tmp/foo/.git/
-> cat .git/config 
[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true

Changing the global config for filemode does not affect this, and so in fact git config --global core.filemode false doesn't do anything because this is always overridden locally.

Therefore, to change the filemode for this repo, change the local config:

$ git config core.filemode false
$ git config core.filemode
false

Given this question/answer there's a possibility it is supposed to work, although it didn't for me.

like image 167
AD7six Avatar answered Sep 19 '22 04:09

AD7six


You can verify what the local setting is with this: git config --local --list

...and set a local value like this:

git config --local core.filemode false

like image 28
Randy Leberknight Avatar answered Sep 23 '22 04:09

Randy Leberknight