为了方便,给测试地址做了git hook,可以参考之前的文章,利用git的hook自动部署代码。现在发现使用exec之类的命令无法获取到错误的输出,获取到的结果相对于直接在终端执行命令少了很多信息,这很不方便调试。
Updating 0430ef4..377d045
在终端则是
Updating 0430ef4..377d045
error: Your local changes to the following files would be overwritten by merge:
public/coding.php
Please, commit your changes or stash them before you can merge.
Aborting
下面这么多的错误信息都没了,没办法知道是因为什么卡住,开始以为PHP函数原因,后来google了一下,才发现是需要更改一下shell的错误输出重定向,使用如下即可
cd /home/wwwroot/*** && /usr/bin/git pull 2>&1
修改之后获取到的错误信息如下
error: Your local changes to the following files would be overwritten by merge: public/coding.php
Please, commit your changes or stash them before you can merge.
Aborting
Updating 0430ef4..fac8fed
正确的如下
From https://git.coding.net/****/****
4454adb..40ba1aa develop -> origin/develop
Updating 4454adb..40ba1aa
Fast-forward
readme.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
这样就很直观了
分享本文到: