git的更新后的脚本不工作 [英] git post-update script does not work

查看:144
本文介绍了git的更新后的脚本不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑我老问题几次之后,我提出一个新的,因为它是现在,一个新的问题。

的.git /挂钩/更新后我有:

 回声一个>> /家庭/ PI /日志
git的更新,服务器信息
混帐藏匿
git的合并测试>> /家庭/ PI /日志

要做出一个自动结帐。所以,我在客户端上运行:

 混帐推测试头:测试

现在我的 /家庭/ PI /日志包含:

  A
更新ae2f44b..04753a9
快进
 应用程序/视图/主/ index.php文件| 2 + -
 1个文件改变时,1插入(+),1缺失( - )

但文件并没有改变!

  $ git的合并测试
已经起床了最新的。

如果我删除脚本,使推并运行 git的藏匿的git合并测试它的工作原理。

更新

有关测试中,我在一个文件中改变了一些从17到20,我可以看到正确的文件版本,如果我跑

  git的显示应用程序/视图/主/ index.php文件

  VIM应用程序/视图/主/ index.php文件

仍包含旧号码。但混帐声称该文件被更新:

  $ git的合并测试
已经起床了最新的。


解决方案

该解决方案是使用后接受亚历如指出。你还需要运行取消设置GIT_DIR 在你的脚本的顶部。

在服务器我创建了一个第二分支切换到它:

  $ git的分支
  主
*测试

我的的.git /挂钩/后接受现在看起来是这样的:

 取消设置GIT_DIR
CD ..
混帐合并主

在我运行混帐推

客户端

After editing my old question a few times, I make a new one because it is a new question now.

In .git/hooks/post-update I have:

echo "a" >> /home/pi/log
git update-server-info
git stash
git merge testing >> /home/pi/log

To make an automated checkout. So I run on the client:

git push testing HEAD:testing

Now my /home/pi/log contains:

a
Updating ae2f44b..04753a9
Fast-forward
 application/views/main/index.php |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

But the file did not change!

$ git merge testing
Already up-to-date.

If I remove the script, make the push and run git stash, git merge testing it works.

Update

For testing I changed a number in a file from 17 to 20. I can see the right file version if I run

git show application/views/main/index.php

but

vim application/views/main/index.php

Still contains the old number. But git claims the file is updated:

$ git merge testing
Already up-to-date.

解决方案

The solution is to use post-receive as Alex pointed out. Also you need run unset GIT_DIR at the top of your script.

On the server I have created a second branch and switched to it:

$ git branch
  master
* testing

My .git/hooks/post-receive now looks like this:

unset GIT_DIR
cd ..
git merge master

On the client I run git push.

这篇关于git的更新后的脚本不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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