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
A solution without fancy bash scripting:
fileMode = true in your .git/config file (or by running git config core.filemode true as others have pointed out)chmod u+x $script as you pointed out). You only have to do this once.The next time you pull from there, git will set the committed executable bit on the file. I also had similar problems, this solved them.
fileMode = true tells git to track the only thing about permissions it can: the executable bit. This means that changes to the executable bit will be recognized by git as changes in the working tree and those changes will be stored in the repo with your next commit.
Once you committed the desired executable bit you can also reset your fileMode to false so next time git won't bother you with such changes when you don't want to commit them.