Git 更新后钩子无法拉取
我目前正在按照此处所述设置 git 模式。
相关服务器运行 Windows Server 2008 R2,使用 copSSH 和 msysGit。
它的要点是一对 git 存储库:一个被推送到的裸存储库,然后是另一个包含实时应用程序的非裸存储库。
推送到的存储库包含一个更新后挂钩,如下所示:
echo
echo "**** Pushing data to Live Server."
echo
cd /cygdrive/c/Repositories/Live || exit
unset GIT_DIR
git pull hub master
exec git-update-server-info
值得注意的是:Live 是非裸存储库,顾名思义,它是实时的。 Live.git 是包含上述钩子并被推送到的裸存储库。如果没有 /cygdrive/ ,我无法 cd 到存储库,这是通过在诊断推送中回显 $pwd 发现的。
在 Live 存储库中成功调用 Pull,问题在于在该更新中定位 Live.git 存储库。我收到“奇怪的球”错误,内容如下:
remote: Pushing data to Live Server.ommand not foundnd not foundle or directory
remote: : not foundpdate-server-infoand not foundand not founddommand not found
hub 通过本地 git shell 定义为远程存储库,如 /c/Repositories/Live.git 和 /cygdrive/c/Repositories/Live.git。
我已经用直接文件夹路径替换了“hub”,甚至尝试了“../Live.git”之类的东西 我所尝试的一切都以 git 更新失败告终。更新命令中 Live.git 的所有尝试路径都是通过 git bash 尝试的,工作目录设置为 Live 存储库并有效。
感谢您的任何线索或帮助!
更新: 我的架构要求我从中心存储库中提取数据,这将花费不必要的空间来解释原因,但情况就是如此。
我做了更多测试并发现了有关我的问题的更多信息: 当我通过 SSH 推送到我的存储库时,prime hub 已成功安装并执行了 pull 命令。当所述 pull 命令尝试解析集线器存储库时,它失败了(正如我上面详细介绍的那样),但事实证明,挂钩中的一系列 ls 命令看不到任何文件夹。我什至在 /cygdrive/c/ 上运行 ls ,只能看到一个名为 usr 的文件夹。我已确保 copSSH 用户对整个文件系统具有完全管理权限(仅用于测试和调试目的)。
我不知道为什么我的路径必须使用/cygdrive/路径,除了copSSH中打包的cygwin之外,我没有安装cygwin。这是否表明我的配置有问题?或者这对于 copSSH + msysGit 设置来说是正常的吗?即使 ls 不会列出存储库文件夹,我如何才能从挂钩挂载主存储库?
I am currently setting up a git schema as described here.
The server in question is running Windows Server 2008 R2, using copSSH and msysGit.
The jist of it is a pair of git repos: one bare repo that is pushed to and then another non-bare repo that contains a live application.
The repo that is pushed to contains a post-update hook that looks as follows:
echo
echo "**** Pushing data to Live Server."
echo
cd /cygdrive/c/Repositories/Live || exit
unset GIT_DIR
git pull hub master
exec git-update-server-info
Of note: Live is the non-bare repo which is, as the name implies, live. Live.git is the bare repo which contains the above hook and is pushed to. I was unable to cd to the repo without /cygdrive/, which was uncovered by echoing $pwd in a diagnostic push.
Pull is successfully called in the Live repo, the problem comes in locating the Live.git repo in that update. I get "odd ball" errors that read like:
remote: Pushing data to Live Server.ommand not foundnd not foundle or directory
remote: : not foundpdate-server-infoand not foundand not founddommand not found
hub is defined as a remote repository via the local git shell as both /c/Repositories/Live.git and /cygdrive/c/Repositories/Live.git.
I've replaced "hub" with direct folder paths, even trying things like "../Live.git"
Everything I have tried has ended in a git update failure. All of the attempted paths for Live.git in the update command were attempted via a git bash with the working directory set to the Live repo and worked.
Thank you for any leads or help!
An update:
My schema requires that I pull from the hub repository, it would take an unnecessary amount of room to explain why, but such is the case.
I have done more testing and found more out about my issue:
When I push via SSH to my repository, the prime hub is successfully mounted and the pull command is executed. When said pull command tries to resolve the hub repository it fails (as I detailed above), but it turns out with a series of ls commands in the hook that no folders can be seen. I even ran an ls on /cygdrive/c/ and can only see a folder called usr. I have ensured that the copSSH user has full administrative privileges on the entire file system (only for testing and debugging purposes).
I do not know why my paths have to use the /cygdrive/ path, I do not have cygwin installed besides the cygwin packaged in copSSH. Is this indicative of a problem in my configuration? or is this normal for copSSH + msysGit setups? How is it possible that I can mount the prime repository from the hook, even if ls will not list the repositories folder?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不应该在 msysgit 的路径中需要
/cygdrive
,除非您还安装了 cygwin (在这种情况下,msysgit mingw 和 cygwin 的组合可能是问题的根源)You shouldn't need
/cygdrive
in paths with msysgit, unless you also have cygwin installed (in which case the combination of msysgit mingw and cygwin might be the source of your problem)您不应该尝试从存储库挂钩运行 git pull 。虽然有些人会说它工作正常,但事实并非如此,并且由于各种因素,其行为可能是不可预测的。
相反,您应该使用诸如此类的方法。 http://toroid.org/ams/git-website-howto
该方法使用裸存储库中的 post-receive 挂钩调用 git checkout 来更新目录。
You shouldn't try to run
git pull
from a repo hook. While some people will say that it works fine, it does not and the behavior can be unpredictable due to various factors.Instead you should use a method such as this one. http://toroid.org/ams/git-website-howto
That method uses a post-receive hook in a bare repo that calls
git checkout
to update a directory.