Scott Watermasysk
Adding Execute Permission to Script in Git
With my SQLite backup script, I mentioned you need to add execute permission after you deploy.
However, I cloned a Rails app off of GitHub today and noticed that the bin/setup worked as expected and had proper execute permissions. 👀
I eventually found my way to the git's update-index command:
Modifies the index. Each file mentioned is updated into the index and any unmerged or needs updating state is cleared.
That description is clear as mud. 😛
But digging further is this option: --chmod=(+|-)x
Set the execute permissions on the updated files.
So here is how to use it.
- Add a new script file or modify an executing one (even with just a comment). This is important because
update-index
will not take effect unless you commit to some change. - Add the change to git:
git add bin/backup
- Execute update-index: `git update-index --chmod=+x bin/backup
- Commit the change:
git commit -m "Now with execute permission"