开发者

Git post-update hook cannot pull

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开发者_StackOverflow社区 the repositories folder?


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)


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜