In a Linux environment, Git tracks a file’s executable bit (+x).
If you want a script to be preserved as an executable file in the repository, you need to explicitly record that permission change in Git.
Add Executable Permission to a File
|
|
This command stages the executable-bit change for script.sh. After you commit and push, other users will keep the same permission state when they pull or clone the repository.
Remove Executable Permission from a File
|
|
Verify the Result
Use the following commands to check file permissions in your working tree:
|
|
If you see something like -rwxr-xr-x, the file is executable. If you see -rw-r--r--, it is not executable.
Notes
git update-index --chmod=+x/-xonly updates the file mode recorded by Git; it does not replace changes to file content.- In team workflows, it is best to commit permission-only changes separately for easier review and tracking.