Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows上的post接收钩子-GIT_WORK_DIR:没有这样的文件或目录_Git - Fatal编程技术网

Windows上的post接收钩子-GIT_WORK_DIR:没有这样的文件或目录

Windows上的post接收钩子-GIT_WORK_DIR:没有这样的文件或目录,git,Git,我尝试在git(windows)上设置我的post接收挂钩。 以下是脚本: #!/bin/sh echo "post-receive hook" GIT_WORK_TREE=/d/test git checkout -f 当我在本地存储库上执行git push时,我看到这个回音消息,脚本被正确调用 但是结账没有运行!控制台视图中有一个错误: remote: fatal: Could not switch to '/d': No such file or directory 但是当我把这个命令

我尝试在git(windows)上设置我的post接收挂钩。 以下是脚本:

#!/bin/sh
echo "post-receive hook"
GIT_WORK_TREE=/d/test git checkout -f
当我在本地存储库上执行git push时,我看到这个回音消息,脚本被正确调用

但是结账没有运行!控制台视图中有一个错误:

remote: fatal: Could not switch to '/d': No such file or directory
但是当我把这个命令放在GitBash中时,它就工作了

从评论中:

GIT_WORK_TREE=/Volumes/D/test git checkout -f
工作

然而,评论意见:

GIT_WORK_TREE=/Volumes/D/test git checkout -f
如果我从另一台计算机上推怎么办?我的windows计算机上有其他克隆,但此路径不可用


这是一个不同的问题,例如可以通过驱动器命名约定来解决:可以决定将远程repo的任何路径(
d:\test
或任何其他路径)关联到特定的驱动器号(
X:
),有了。

我让mysysgit运行在从本地工作站推送到的Web服务器上,并使用以下post receive脚本:

#!/bin/sh
git --work-tree=/cygdrive/d/www --git-dir=/cygdrive/d/CodeRepositories/tempRepo.git checkout -f

一开始让我感到困惑的是文件不是UNIX格式,您可以使用Notepad++来更改它。注意,我使用cygwin来执行push-over-SSH,因此可能需要修改目录名。

是否使用cygwin而不是msysgit附带的bash?因为使用cygwin,路径将是
/cygdrive/d/test
。不,我只使用Git Bash安装了Git,而没有将Git添加到路径中。也许我应该尝试将git添加到PATH?我不认为
PATH
是问题所在(您可以
echo
检查
$PATH
)。也可以尝试设置
GIT\u DIR
。同时显示
pwd
,以及
ls/d
。这里有可疑的东西。看起来我得到的是本地磁盘,而不是远程机器
remote:/cygdrive/d/test remote:ls:/d:没有这样的文件或目录remote:/Volumes/d/Git/myrepo.Git remote:fatal:无法切换到“/cygdrive/d”:没有这样的文件或目录
这是以下接收后脚本的结果:
#/bin/sh导出GIT\u WORK\u TREE=/cygdrive/d/test echo$GIT\u WORK\u TREE ls/d pwd GIT checkout-f