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.

  1. 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.
  2. Add the change to git: git add bin/backup
  3. Execute update-index: `git update-index –chmod=+x bin/backup
  4. Commit the change: git commit -m "Now with execute permission"