在Windows下的Git钩子 [英] Git Hook under Windows

查看:395
本文介绍了在Windows下的Git钩子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 #!/ bin / 

我有以下代码在hook post-receive的工作目录中签出: sh
git --work-tree = d:/ websites / __ gitweb --git-dir = d:/ _ gitrepo.git / checkout -f

不幸的是,它似乎并不奏效。但是,当我在windows命令行(cms)中输入这个命令时,该命令仍然有效:

  git --work-tree = d:/ websites / __ gitweb --git-dir = d:/ _ gitrepo.git / checkout -f 

我检查了权限和执行属性,但没有任何结果。

我想我越来越近了。现在我知道问题是什么,但我不知道为什么会发生这种情况。钩子实际上正在被触发,但我收到了这条消息:

  remote:从存储库开始复制到工作树... 
remote:fatal:不是git存储库:'d:/ _ gitrepo.git /'
remote:已完成。

我试图改变d:的路径到整个网络路径,但它仍然没有工作。如果我去远程存储库,并且我做了一个git日志,那么这些更改就在那里,如果我用sh运行这个钩子,它就可以工作。
为什么它明确表示它不是git存储库?

解决方案

我终于搞定了!
这真的很奇怪。我必须输入一个 pwd 来查看批处理的实际位置,并显示服务器上的挂接位置。但是,在下一行中,我添加了一个主机名,它向我显示了我的本地主机名。
然后我添加整个路径,就像:

$ $ $ $ $ $ $ $ $ bin $
echoStarting从存储库复制到工作树...
pwd
主机名
git --work-tree = //远程主机/ d $ / Webseiten / __ gitweb --git-dir = //远程主机/ d $ / _ gitr
epo.git checkout -f
echoFinished。

我希望这个解决方案适用于某人


I have the following code to checkout in a working directory in the hook post-receive:

#!/bin/sh
git --work-tree=d:/websites/__gitweb --git-dir=d:/_gitrepo.git/ checkout -f

Unfortunately it doesn't seem to work. However, the command does work when I enter just this in the windows command line (cms):

git --work-tree=d:/websites/__gitweb --git-dir=d:/_gitrepo.git/ checkout -f

I have checked the permissions and the executing attributes but nothing.

UPDATE:

I think I'm getting closer. Now I know what the problem is but I don't know why is this happening. The hook is actually being triggered but I receive this message:

remote: Starting copy from repository to work tree...
remote: fatal: Not a git repository: 'd:/_gitrepo.git/'
remote: Finished.

I have tried to change the path of d: to the whole network path but it still doesn't work. If I go to the remote repository and I do a git log, the changes are there and if I run the hook with sh, it works. Why is it saying that it is not a git repository when clearly it is?

解决方案

I finally got it working! This is really weird. I had to type a pwd to see where actually is the batch being located and it showed the hook location on the server. However, in the next line I added a hostname and it showed me my local hostname. Then I add the whole path just like:

#!/bin/sh
echo "Starting copy from repository to work tree..."
pwd
hostname
git --work-tree=//remotehost/d$/Webseiten/__gitweb --git-dir=//remotehost/d$/_gitr
epo.git checkout -f
echo "Finished."

I hope this solution works for someone

这篇关于在Windows下的Git钩子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆