我的 gitlab 帐户中有 2 个项目,名为 zip/production (master) 和 map/production (forked from master)。每当我对 zip/production 进行更改时,都应自动将其更新为 map/production,但应保留 map/production 中的其他文件。这可能吗?
问问题
269 次
1 回答
0
不仅可能,而且非常容易!
# .git/hooks/post-receive on the remote:
#!/usr/bin/bash
IFS=' '
while read local_ref local_sha remote_ref remote_sha
do
echo "$remote_ref" | egrep '^refs\/heads\/[A-Z]+-[0-9]+$' >/dev/null && {
ref=`echo $remote_ref | sed -e 's/^refs\/heads\///'`
echo Forwarding feature branch to features-only repository: $ref
git push -q features-only $ref --force
}
done
此示例仅采用分支的子集(采用 Jira 问题格式,XYZ-1234)并将它们转发到第二个存储库。当然,您可以离开条件以转发所有内容。
于 2016-09-15T15:53:34.290 回答