简体   繁体   中英

How to set 'GIT_WORK_TREE' to specific driver in computer

I'm trying using Git hook to deploy mt project in FTP.

By the way, I use 'CYGWIN' to build.

Here's my environment and settings.

FTP in remote

C:\\cygwin64\\test_ftp\\

Cygwin in remote

C:\\cygwin64\\

remote's root

C:\\cygwin64\\home\\Administrator\\

git/hooks/post-receive

#!/bin/sh

DEPLOY_DIR=~/../../test_ftp
echo "Start deploying..."
GIT_WORK_TREE=$DEPLOY_DIR git checkout -f
echo "Deployment is completed."

It works fine.

"git push" will trigger "post-receive" and deploy files in "C:\\cygwin64\\test_ftp\\".

.

Now I want to change the path of "test_ftp" to "C:\\test_ftp\\",
I try to set "DEPLOY_DIR=~/../../../test_ftp" and run "git push".

Error occurs in deploy task:

remote: fatal: This operation must be run in a work tree

Is there any way to set GIT_WORK_TREE's path out of cygwin??

I found the answer later.

  1. Edit the file "C:\\ctgwin64\\etc\\passwd".

    Replace "/home/Administrator" to "/cygdrive/c".

  2. Edit the file "C:\\ctgwin64\\etc\\sshd_config".

    Set "StrictModes no"
    Set "AuthorizedKeysFile /path/to/your/authorized_keys"

  3. Restart the "CYGWIN sshd" service.
  4. Try to push something in client side.

It works!!

Now I can login with key, triggered "post-receive" as usual and deploy files in "C:\\test_ftp".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM