Git changes my file permissions upon checkout

后端 未结 5 837
误落风尘
误落风尘 2020-12-02 22:51

Our workflow is develop on a local machine, commit the changes to a central repository, then check out the branch of that repository that we need.

The problem is tha

5条回答
  •  广开言路
    2020-12-02 23:11

    For me, the best solution was creation of a shell script that fixes the permissions. For example:

    .git/hooks/post-checkout:
    
    #!/bin/sh
    chmod +x  tools/*
    

    Btw, checkout is not the only case when git does mess with permissions, it's also when you pull. I handle that with .git/hooks/post-merge hook.

    Ideally, you can create a shell script that fixes permissions somewhere in your repo (e.g. tools/fixpermissions.sh), and call it in both hooks. Don't forget to change the permissions for that file manually ;)

    #!/bin/sh
    chmod a+x tools/fixpermissions.sh
    tools/fixpermissions.sh
    

提交回复
热议问题