git checkout在post-receive中与子模块裸机 [英] git checkout bare with submodules in post-receive
问题描述
我如何在包含子模块的post-receive钩子中检出服务器上的裸仓库?
我现在将它作为post-receive钩子: / p>
#!/ bin / bash
#http://blog.ekynoxe.com/2011/ 10/22 / git-post-receive-for-multiple-remote-branches-and-work-trees /
#post-receive hook在推送到光秃秃的
#repo后检出开发分支
#路径必须存在
livepath =/ var / www / live
devpath =/ var / www / dev
while read oldrev newrev ref
do
branch =`echo $ ref | cut -d / -f3`
#if [[master==$ branch]];然后
#git --work-tree = $ livepath checkout -f $ branch
#echo'Changes live live。'
#fi
if [[develop== $ branch]];然后
git --work-tree = $ devpath checkout -f $ branch
echo'更改推送到开发者'
fi
完成
但是有了这个子模块不会被初始化。
我试着做这个测试手册:
cd / var / www / dev
git --work-tree / var / www / dev - -git / dir /git/myrepo.git子模块init
git --work-tree / var / www / dev --git / dir /git/myrepo.git子模块更新
子模块更新
命令失败,显示以下错误消息:
致命:工作树'/ var / www / dev'已经存在。
将'https://github.com/yiisoft/yii.git'克隆到子模块路径'yii'中失败
这个行为已经被(未回答)质疑: Git子模块单独的work_tree
如果它们不在那里重新初始化它们也是很好的选择。
只需创建一个克隆,执行 cd
+ 在你的钩子中拉
。
how may I checkout a bare repository on my server in a post-receive hook that includes submodules?
I currently have this as a post-receive hook:
#!/bin/bash
# http://blog.ekynoxe.com/2011/10/22/git-post-receive-for-multiple-remote-branches-and-work-trees/
# post-receive hook that checks out development branch after a push to the bare
# repo
# paths must exist
livepath="/var/www/live"
devpath="/var/www/dev"
while read oldrev newrev ref
do
branch=`echo $ref | cut -d/ -f3`
#if [[ "master" == "$branch" ]]; then
# git --work-tree=$livepath checkout -f $branch
# echo 'Changes pushed live.'
#fi
if [[ "develop" == "$branch" ]]; then
git --work-tree=$devpath checkout -f $branch
echo 'Changes pushed to dev.'
fi
done
But with this the submodules wont get initialized.
I tried doing this for testing manual:
cd /var/www/dev
git --work-tree /var/www/dev --git/dir /git/myrepo.git submodule init
git --work-tree /var/www/dev --git/dir /git/myrepo.git submodule update
submodule update
command failed with this error messages:
fatal: working tree '/var/www/dev' already exists.
Clone of 'https://github.com/yiisoft/yii.git' into submodule path 'yii' failed
That behavior is already (unanswered) questioned here: Git submodules with separate work_tree
It would also be good if it would not reinitialize them if they are alredy there.
--work-tree
does not work well with submodules (becoz submodule need another repos, but it can't put in your worktree). You need a separate clone for that.
Just create a clone, do a cd
+ pull
in your hook.
这篇关于git checkout在post-receive中与子模块裸机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!