재귀 적으로 Git 업데이트 서브 모듈 (submodule of FrameworkA) 하위 모듈을

내 프로젝트 구조

ProjectA
-FrameworkA (submodule)
--Twig (submodule of FrameworkA)

하위 모듈을 재귀 적으로 업데이트하려면 어떻게해야합니까? 이미 git 명령을 시도했습니다 (ProjectA 루트에서)

git submodule foreach git pull origin master

또는

git submodule foreach --recursive git pull origin master

Twig 파일은 가져올 수 없습니다.



답변

git submodule update --recursive

–init 옵션을 사용하여 초기화되지 않은 하위 모듈을 초기화 할 수도 있습니다.

git submodule update --init --recursive

참고 : 일부 이전 버전의 Git에서이--init 옵션 을 사용하면 이미 초기화 된 하위 모듈이 업데이트되지 않을 수 있습니다. 이 경우 --init옵션 없이 명령을 실행해야합니다 .


답변

내가 사용하는 방법은 다음과 같습니다

git submodule update --init --recursive
git submodule foreach --recursive git fetch
git submodule foreach git merge origin master

답변

하위 모듈의 기본 분기가 (내 경우에는 많이 발생 하지 않음) master 발생할 수 있으므로 전체 Git 하위 모듈 업그레이드를 자동화하는 방법입니다.

git submodule init
git submodule update
git submodule foreach 'git fetch origin; git checkout $(git rev-parse --abbrev-ref HEAD); git reset --hard origin/$(git rev-parse --abbrev-ref HEAD); git submodule update --recursive; git clean -dfx'

답변

최근 Git (v2.15.1을 사용하고 있습니다)에서 다음은 업스트림 하위 모듈 변경 사항을 하위 모듈에 재귀 적으로 병합합니다.

git submodule update --recursive --remote --merge

당신은 추가 할 수 --init있는 초기화되지 않은 서브 모듈 사용을 초기화--rebase 병합 대신 리베이스하려는 경우에 수 있습니다.

나중에 변경 사항을 커밋해야합니다.

git add . && git commit -m 'Update submodules to latest revisions'