得到“致命的:不是git仓库:'。'”当使用post-update钩子执行另一个repo上的'git pull'时 [英] getting "fatal: not a git repository: '.'" when using post-update hook to execute 'git pull' on another repo

查看:124
本文介绍了得到“致命的:不是git仓库:'。'”当使用post-update钩子执行另一个repo上的'git pull'时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是git的新手,所以如果我在这里误用术语,我会道歉(并请纠正我),但我会尽我所能。

我是试图在Web服务器上建立一个裸Git回购(集线器)和开发网站工作副本(主要)。我试图在这篇文章之后对其进行设置。我希望在推送到hub回购时更新开发工作副本。我的印象是这个正确的钩子是 post-update ,这是我创建的:

 #!/ bin / sh 
whoami
cd / path / to / working-copy /
RET =`git pull`
echo $ RET



更新



推送从本地回购更改到裸集线器我从更新后的脚本中获得以下输出:

  remote:sites 
remote:fatal:不是git仓库:'。'

但是如果我进入SSH服务器作为用户的'网站',并手动执行这个脚本它工作得很好关于这个钩子或脚本会发生什么问题的任何想法?

解决方案

这是最终奏效的脚本。我认为我最初遗漏的那一点妨碍了它的远程工作: unset GIT_DIR

 #!/ bin / sh 
cd / path / to / working-copy / ||退出
取消设置GIT_DIR
git pull回购分支

执行git-update-server-info


I'm new to git so I apologize (and please correct me) if I misuse terminology here, but I'll do my best.

I'm trying to set up a bare git repo (hub) and a development site working copy (prime) on a web server. I've tried to pattern it after this article. I want the development working copy to be updated whenever the hub repo is pushed to. I'm under the impression that the proper hook for this is post-update, which I have created like so:

#!/bin/sh
whoami
cd /path/to/working-copy/
RET=`git pull`
echo $RET

Update

When I push changes from my local repo to the bare hub I get the following output from the post-update script:

remote: sites
remote: fatal: Not a git repository: '.'

However if I SSH into the server as user 'sites' and execute this script manually it works great Any ideas as to what might be going wrong with this hook or script?

解决方案

Here is the script that ultimately worked. I think the bit I was originally missing that prevented it from working remotely was the unset GIT_DIR

#!/bin/sh
cd /path/to/working-copy/ || exit
unset GIT_DIR
git pull repo branch

exec git-update-server-info

这篇关于得到“致命的:不是git仓库:'。'”当使用post-update钩子执行另一个repo上的'git pull'时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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