2012-01-08 6 views
3

git submodule foreach 명령이 저에게 맞지 않는 이유를 알고 싶습니다. 몇 개의 서브 모듈을 가진 자식 저장소를 복제했습니다. 서브 모듈 소스를 다운시키기 위해 모든 서브 모듈을 초기화하고 업데이트하려고했습니다. 없이 (git submodule foreach가 작동하지 않음

git submodule foreach init 
git submodule foreach update 
git submodule foreach update --init 
git submodule foreach --recursive git submodule update --init 

모든 명령을 실행할 수 있지만 출력없이 ... 내가 가서 초기화하면/별도로 각 모듈을 업데이트합니다 :하지만 서브 모듈 foreach는 나를 위해 작동하지 않는 자식 ... 나는 몇 가지를 시도하려고 어떤 foreach를 사용할 때) 아무런 문제가 없다.

아이디어가 있으십니까?

답변

5

git submodule init 또는 git submodule update.gitmodules에 등록 모든 서브 모듈을 위해 일하기로되어 있으므로 각 서브 모듈 그들을 실행하는 데 이해가되지 않습니다.

서브 모듈 내에 서브 모듈이있는 경우 git submodule update --recursive모두 서브 모듈을 재귀 적으로 처리합니다.

+0

확인이 확실했다 ... 그래서 foreach는 '명령을 사용하는 것이 적합한 경우? –

+0

@PrimozRome :이 외부 스크립트 예제와 같이 각 하위 모듈에서 사용하려는 명령에 대해 : http://stackoverflow.com/questions/5889246/git-submodule-foreach-execute-read – VonC

3

복제 한 후에는 일반적으로 할 필요가 있습니다 :

git submodule update --init --recursive 

이 처음에 완료되면, 당신은 --init 옵션을 놓습니다.

init 옵션은 .gitmodules 파일에 지정된 url을 하위 모듈 repo 구성으로 복사하는 명령의 일부입니다. 특정 리모컨을 사용하고 있고 사용하지 않으려는 프로젝트로 프로젝트를 옮겼다면이 작업을 원하지 않을 수 있습니다. 이것의 전형적인 경우는 오히려 GitHub에서 프로젝트 포크를 사용하고 최상위 레벨 repo가 ​​주 프로젝트를 가리킬 때입니다. 그것은 다음과 같습니다, 당신은 당신의 나무 fo를 루트에서 .gitmodules 파일이 필요

-

git submodule init 
git submodule update 

:

2

당신은 실행해야합니다. 여기

[submodule "LiveReload/Compilers"] 
     path = LiveReload/Compilers 
     url = git://github.com/livereload/livereload-plugins.git 
[submodule "Shared/libs/fsmonitor"] 
     path = Shared/libs/fsmonitor 
     url = git://github.com/andreyvit/fsmonitor.c.git 
[submodule "js"] 
     path = js 
     url = git://github.com/livereload/livereload-js.git 

는 출력이 위를 기반으로 보일 것입니다 방법은 다음과 같습니다

Nicks-MacBook:LiveReload2 admin$ git submodule init 
Submodule 'LiveReload/Compilers' (git://github.com/livereload/livereload-plugins.git) registered for path 'LiveReload/Compilers' 
Submodule 'Shared/libs/fsmonitor' (git://github.com/andreyvit/fsmonitor.c.git) registered for path 'Shared/libs/fsmonitor' 
Submodule 'js' (git://github.com/livereload/livereload-js.git) registered for path 'js' 
Nicks-MacBook:LiveReload2 admin$ git submodule update 
Cloning into 'LiveReload/Compilers'... 
remote: Counting objects: 7571, done. 
remote: Compressing objects: 100% (5446/5446), done. 
remote: Total 7571 (delta 2326), reused 6733 (delta 1488) 
Receiving objects: 100% (7571/7571), 7.80 MiB | 2.73 MiB/s, done. 
Resolving deltas: 100% (2326/2326), done. 
Submodule path 'LiveReload/Compilers': checked out 'd770710edc2362caf4ed9adf303da1edc9e6e494' 
Cloning into 'Shared/libs/fsmonitor'... 
remote: Counting objects: 132, done. 
remote: Compressing objects: 100% (79/79), done. 
remote: Total 132 (delta 73), reused 112 (delta 53) 
Receiving objects: 100% (132/132), 23.29 KiB, done. 
Resolving deltas: 100% (73/73), done. 
Submodule path 'Shared/libs/fsmonitor': checked out '1290027aea3a8e3f7fe06e3c228a16240c0fc17f' 
Cloning into 'js'... 
remote: Counting objects: 745, done. 
remote: Compressing objects: 100% (413/413), done. 
remote: Total 745 (delta 301), reused 703 (delta 259) 
Receiving objects: 100% (745/745), 864.22 KiB | 820 KiB/s, done. 
Resolving deltas: 100% (301/301), done. 
Submodule path 'js': checked out '6aa86b01479c3aad785e9623f39cfcde2b8615f 
관련 문제