Automatically apply “git update-index --chmod=+x” to executable files

后端 未结 6 696
Happy的楠姐
Happy的楠姐 2020-11-29 19:53

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

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-29 20:12

    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.

提交回复
热议问题