How to commit file permissions in a git repository

Now and then I put a deploy.sh file in my repositories. It’s useful when I have to work elsewhere than on a Forge server.

When you create an executable file like this and commit it to your repository, by default it is not executable on the server because Git doesn’t commit file permissions by default.

The solution is 4 commands :

git update-index --chmod=+x deploy.sh
git ls-tree HEAD
git commit -m "Make deploy.sh executable"
git push

Now the next time you’ll pull your changes to your server, you’ll be able to run the ./deploy.sh script.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.