I frequently add bash scripts to my git repository, and the scripts have executable permissions in the linux filesystem prior to the git add
. But after pushing
I don't think this can be done on the git add
command, but you might be able to run a script just right after you run the git commit
command, but before the commit is actually created.
Take a look at the pre-commit hook.
http://git-scm.com/book/en/Customizing-Git-Git-Hooks
Basically just create a file in your .git/hooks/ folder called pre-commit. (There should be samples already in your hooks folder, rename them to remove the ".sample" at the end to activate one.)
Theres a gotcha. Make sure your script runs git stash -q
first so that your working on the actual staged versions of files.