如何在计算机中将 'GIT_WORK_TREE' 设置为特定驱动程序
How to set 'GIT_WORK_TREE' to specific driver in computer
我正在尝试使用 Git 挂钩在 FTP 中部署 mt 项目。
对了,我是用'CYGWIN'搭建的
这是我的环境和设置。
FTP 远程
C:\cygwin64\test_ftp\
远程中的 Cygwin
C:\cygwin64\
远程的根目录
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."
它工作正常。
"git push" 将触发 "post-receive" 并在 "C:\cygwin64\test_ftp\" 中部署文件。
.
现在我想把"test_ftp"的路径改成"C:\test_ftp\",
我尝试设置 "DEPLOY_DIR=~/../../../test_ftp" 和 运行 "git push".
部署任务出错:
remote: fatal: This operation must be run in a work tree
有什么方法可以设置 GIT_WORK_TREE 的 cygwin 路径吗??
后来我找到了答案。
- 编辑文件"C:\ctgwin64\etc\passwd"。
Replace "/home/Administrator" to "/cygdrive/c".
- 编辑文件"C:\ctgwin64\etc\sshd_config"。
Set "StrictModes no"
Set "AuthorizedKeysFile /path/to/your/authorized_keys"
- 重新启动 "CYGWIN sshd" 服务。
- 尝试在客户端推送一些东西。
有效!!
现在我可以使用密钥登录,像往常一样触发 "post-receive" 并在 "C:\test_ftp" 中部署文件。
我正在尝试使用 Git 挂钩在 FTP 中部署 mt 项目。
对了,我是用'CYGWIN'搭建的
这是我的环境和设置。
FTP 远程
C:\cygwin64\test_ftp\
远程中的 Cygwin
C:\cygwin64\
远程的根目录
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."
它工作正常。
"git push" 将触发 "post-receive" 并在 "C:\cygwin64\test_ftp\" 中部署文件。
.
现在我想把"test_ftp"的路径改成"C:\test_ftp\",
我尝试设置 "DEPLOY_DIR=~/../../../test_ftp" 和 运行 "git push".
部署任务出错:
remote: fatal: This operation must be run in a work tree
有什么方法可以设置 GIT_WORK_TREE 的 cygwin 路径吗??
后来我找到了答案。
- 编辑文件"C:\ctgwin64\etc\passwd"。
Replace "/home/Administrator" to "/cygdrive/c".
- 编辑文件"C:\ctgwin64\etc\sshd_config"。
Set "StrictModes no"
Set "AuthorizedKeysFile /path/to/your/authorized_keys" - 重新启动 "CYGWIN sshd" 服务。
- 尝试在客户端推送一些东西。
有效!!
现在我可以使用密钥登录,像往常一样触发 "post-receive" 并在 "C:\test_ftp" 中部署文件。