git的更新后的脚本不工作 [英] git post-update script does not work
问题描述
编辑我老问题几次之后,我提出一个新的,因为它是现在,一个新的问题。
在的.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屋!