I need a binary file in repo with tests (it is a mp3 file). The file was committed at first with 644 rights, and I would rather see it as 444.
While git has no problem with detecting file attribute change for text files, it seems to not recognize filemode change for binary.
Given:
tar czf foo.bin /usr/include/*.h
chmod 644 foo.bin
git add foo.bin
git commit -m 'foo headers'
gives effect as expected:
# [master 1509a71] foo headers
# 1 file changed, 0 insertions(+), 0 deletions(-)
# create mode 100644 foo.bin
But lets change rights to read-only:
chmod 444 foo.bin
git add foo.bin
git commit --amend --no-edit
Then I would expect foo.bin
to have proper attributes, but it has not:
# [master 0da87b5] foo headers
# 1 file changed, 0 insertions(+), 0 deletions(-)
# create mode 100644 foo.bin
git --no-pager show --pretty="format:"
# diff --git a/foo.bin b/foo.bin
# new file mode 100644
# index 0000000..08c1e71
# Binary files /dev/null and b/foo.bin differ
this is a brand new repo and git config core.fileMode
is set to true
, of course.
So my questions are:
Why it is happening?
How can I force git to recognize filemode change?
EDIT:
TL;DR - git tracks only executable bit, see linked answer