2012-06-24 3 views
4

서브 모듈을 포함하는 수신 후크에서 서버의 맨 처지를 어떻게 체크 아웃 할 수 있습니까?서브 모듈과 함께 맨손으로 체크 아웃

나는 현재이 포스트받을 후크로 있습니다

#!/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 

그러나 서브 모듈 늘 초기화 얻을이와

.

내가 테스트 매뉴얼이 일을 시도 :

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 명령이 오류 메시지와 함께 실패

fatal: working tree '/var/www/dev' already exists. 
Clone of 'https://github.com/yiisoft/yii.git' into submodule path 'yii' failed 

을 그 행동이 이미 (답) 여기에 의문을 제기입니다 : Git submodules with separate work_tree

그것을 그들이 거기 alredy 인 경우에 그들을 다시 초기화하지 않는 경우에 좋을.

답변

0

--work-tree은 하위 모듈과 잘 작동하지 않습니다 (becoz 하위 모듈에는 다른 repos가 필요하지만 작업 트리에는 넣을 수 없습니다). 이를 위해 별도의 복제가 필요합니다.

클론을 만들려면 cd + pull을 사용하십시오.

+0

git 프로젝트에 서브 모듈이 포함되어있는 경우 현재 버전의 git에서는 작동하지 않는다고 생각합니다. 방금 당신이 제안한 복제본을 만들었고, git 변수를 해제하고, 그 repo에서'git pull '을했습니다. 아직도 내가 전에 시도했던 방식으로 가능해야한다고 생각한다. – kmindi

관련 문제