Git is changing my file's permissions when I push to server

后端 未结 2 935
盖世英雄少女心
盖世英雄少女心 2020-11-30 04:41

I am using git to manage a website on a server.

I have a local repository shown below

local@workstation:myapp$ ls -l | awk \'{k=0;for(i=0;i<=8;i++         


        
2条回答
  •  时光取名叫无心
    2020-11-30 05:38

    To extend the comment of @ThomasReggi that serves as a solution to the problem of changing permissions when deploying through git, I leave my implemented solution. You can add a command in the hooks / post-receive file (or whatever hook you are using)

    Before the line with the git command --work-tree = (line that performs the deploy) Add some "echo" and the display of the current umask, the setting to the umask necessary to perform the deployment correctly and again the display of the current umask to confirm the change. (This way it can be seen (debug) when performing the deploy)

    echo "Ref $ ref received. Deploying $ {BRANCH} branch to production ..."
    # SHOW current uMask
    echo "Current uMASK:"
    umask
    echo "Set uMASK to 0022"
    umask 0022
    echo "New uMASK seted to ..."
    umask
    echo "end umask conf"
    
    # deploy
    HUB_VERBOSE = 1
    git --work-tree = $ TARGET --git-dir = $ GIT_DIR checkout -f
    

    This way the umask is only changed for the current session, without affecting the rest of the ssh connections. And also the files are deployed with the necessary permissions from their creation / modification, instead of using a command after the deployment to re-set the necessary permissions, causing your application to fail during the time it takes to apply the appropriate permissions.

    If your permission problem affects your php application, it seems that this problem has to do with how you run php (DSO, suPHP, suEXEC) because each of them needs different permission settings to run correctly. If you migrated from server, or changed the php handler it is problem that you will experience this problem.

提交回复
热议问题