无法从Git post-receive hook中检测到分支 [英] Not able to detect branch from Git post-receive hook
问题描述
<$在远程回购站点上有一个post接收挂钩设置,试图确定传入推送的分支名称,如下所示: c $ c> $ branch =`git rev-parse --abbrev-ref HEAD`
但是,我发现无论我从我的$ branch变量推送的分支是否设置为'master'。
任何想法?
post-receive钩子获取与pre-receive相同的数据,而不是参数,但是来自stdin。以下是发送给所有参考:
oldRev(空格)newRev(空格)refName(换行符)
你可以用这个bash脚本解析出ref名字:
while read oldrev newrev ref
do
echo$ ref
done
I've got a post receive hook setup on the remote repo that tries to determine the branch name of the incoming push as follows:
$branch = `git rev-parse --abbrev-ref HEAD`
What i'm finding, though, is that no matter what branch I push from my $branch variable gets set with 'master'.
Any ideas?
The post-receive hook gets the same data as the pre-receive and not as arguments, but from stdin. The following is sent for all refs:
oldRev (space) newRev (space) refName (Line feed)
You could parse out the ref name with this bash script:
while read oldrev newrev ref
do
echo "$ref"
done
这篇关于无法从Git post-receive hook中检测到分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!