更新后的Git Hook没有查找目录 [英] Post-Update Git Hook Not Finding Directory

查看:492
本文介绍了更新后的Git Hook没有查找目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设置了一个环境,可以将工作站上的本地更改推送到Hub存储库(远程),然后更新挂钩将自动更新我的暂存网站,即Prime 。我这样做是为了让我可以看到当我推送到远程集线器时,我的更改会自动反映到我的暂存站点中。



该设置基于这篇文章。我的服务器是Windows 2012,我在服务器和工作站上都​​使用了MSysGit(Windows 7)。



当我手动执行所有操作时,一切正常从我的本地仓库到集线器,然后手动提取/合并为素数。我的问题是当我尝试通过更新后的钩子来完成提取/合并时。



当我对集线器提交更改时,我得到的输出是:

  c:\ Code4X \GIT\stage> git push stage master 
计数对象:11,完成。
使用多达8个线程的增量压缩。
压缩对象:100%(6/6),完成。
写入对象:100%(6/6),518字节,完成。
合计6(增量5),重用0(增量0)
远程:
远程:****将更改拉入Live [Stage的更新后的挂钩]
remote:
remote:hooks / post-update:line 12:cd:/c/websites/myproject.staging:No
这样的文件或目录
到w:/stage.git
ce1e2ea..93e11f4 master - > master

我的post-update钩子是:

 #!/ bin / sh 

echo
echo****将更改拉入Live [Stage的更新后的挂钩]
echo

cd /c/websites/myproject.staging ||退出
取消设置GIT_DIR
git pull阶段主设备

执行git update-server-info

我可以启动一个bash命令行管理程序shell并轻松地转到该目录,所以我不确定问题所在。



我也试过:


  • 在我的PATH中包含git \ cmd

  • 封闭路径我试图cd到引号()

  • 让我的shebang指向#!/ c / progra〜1 / git / bin / sh



希望这是显而易见的,对于这个问题有什么想法?

解决方案

I just 通过在我的一个项目上做了一些类似的事情,看起来您有正确的想法。



 #!/ bin / sh 
unset GIT_DIR
cd ..
#你现在在项目根目录
cd ../project.prime
git pull阶段主控

我想我会让你知道我在做什么,因为这可能会帮助你。这个脚本会在每次回购更新时强制更新工作副本:

 #!/ bin / sh 
unset GIT_DIR
cd ..
git checkout -f


I am setting up an environment where I can push changes done locally on my workstation to "Hub" repository (which is a remote) and then a post-update hook will automatically update my staging web site, which is the "Prime". I'm doing this so that I can see my changes get automatically reflected in my staging site when I push to my remote hub.

This set up is based on this article. My server is Windows 2012 and I'm using MSysGit on both the server and my workstation (Windows 7).

Everything is working fine when I do everything manually -- push from my local repo to the hub and then manually fetch/merge into the prime. My problem is when I try to have the fetch/merge be done by a post-update hook.

When I commit a change to my hub, the output I get is:

c:\Code4X\GIT\stage>git push stage master
Counting objects: 11, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 518 bytes, done.
Total 6 (delta 5), reused 0 (delta 0)
remote:
remote: **** Pulling changes into Live [Stage's post-update hook]
remote:
remote: hooks/post-update: line 12: cd: /c/websites/myproject.staging: No
such file or directory
To w:/stage.git
   ce1e2ea..93e11f4  master -> master

My post-update hook is:

#!/bin/sh

echo
echo "**** Pulling changes into Live [Stage's post-update hook]"
echo

cd /c/websites/myproject.staging || exit
unset GIT_DIR
git pull stage master

exec git update-server-info

I'm able to fire up a bash cmd shell and cd to the directory without problem, so I'm not sure what the problem is.

I've also tried:

  • including git\cmd in my PATH
  • enclosing the path I'm trying to cd to in quotes (")
  • having my shebang point to #!/c/progra~1/git/bin/sh

Hopefully it's something obvious. Any thoughts as to what the problem is?

解决方案

I just got through doing something somewhat similar on one of my projects. It looks like you have the right idea.

Try using relative paths instead.

#!/bin/sh
unset GIT_DIR
cd ..
# You are now in the project root
cd ../project.prime
git pull stage master

I figured I'd let you know what I'm doing, as this may help you out. This script will force update the working copy every time the repo gets updated:

#!/bin/sh
unset GIT_DIR
cd ..
git checkout -f

这篇关于更新后的Git Hook没有查找目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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