![](/img/trans.png)
[英]Git post-receive hook to checkout each branch to different folders?
[英]how to process files on a branch in post-receive hook in git
我有一个远程服务器,我在其上创建了一个裸git存储库。
我想创建一个钩子,以便给定脚本在任何给定分支上接收的最新代码上运行。
我知道post-receive
hook可以用于它。 但是我想做以下事情:
我该怎么办?
请参阅“ Git post-receive for multiple remote branches and work-trees ”中的两种技术:
#!/bin/bash
while read oldrev newrev ref
do
branch=`echo $ref | cut -d/ -f3`
if [ "master" == "$branch" ]; then
git --work-tree=/path/under/root/dir/live-site/ checkout -f $branch
echo 'Changes pushed live.'
fi
if [ "dev" == "$branch" ]; then
git --work-tree=/path/under/root/dir/dev-site/ checkout -f $branch
echo 'Changes pushed to dev.'
fi
done
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.