How can we have git
automatically add chmod
permissions for executables when committing?
I have a directory on my Windows, where I've created some executable files (shell scripts and binaries themselves). git bash
reveals this.
-rw-r--r-- Makefile
-rw-r--r-- file.c
-rwxr-xr-x file-test.sh* [executable]
drwxr-xr-x subdir/ [might have some executable inside]
What I would like is that when I clone onto my Linux, the permissions be the same.
Normally, I just git add . && git commit -m "test" && git push
and git pull
from the other side, but on Linux the executable permissions are lost:
-rw-r--r-- Makefile
-rw-r--r-- file.c
-rwxr-xr-- file-test.sh [not executable]
drwxrwxr-x subdir/ [all files inside are not executable]
I instead tried to run git add . --chmod+x
on Windows git bash
, but this turned everything into an executable, not just what was originally an executable:
-rwxrwxr-x Makefile* [executable]
-rwxrwxr-x file.c* [executable]
-rwxrwxr-x file-test.sh* [executable]
drwxrwxr-x subdir/
The alternative is manually changing each permission on my Windows through git update-index --add --chmod=+x file-test.sh subdir/...
, but this is not what I want.
How can we commit the executables permissions without specifying this manually?
I prefer not to go down a script path and only use git
if possible