Git commit a permission bit

When the file permission bits of a script in git are missing the executable bit, you can't directly execute this script after cloning the repository. Typically, the permission looks like -rw-rw-r--, but should be -rwxrwxr-x. To fix and commit such missing executable bits on a script in your git repo, follow the three steps below.

Step one: use the regular chmod command to set the permission bits right.

$ chmod +x the_script.sh 

Step two: add the permission change to the index.

$ git update-index --chmod=+x the_script.sh 

Step three: commit the change.

$ git commit -m "Add executable permission bits" 

The file permissions are corrected, and the script can now be executed as expected.


related blogs: