모든 git 하위 모듈에 대한 최신 변경 내용 가져오기
Git 서브모듈을 사용하여 우리가 개발한 다른 많은 라이브러리에 의존하는 몇 개의 대형 프로젝트를 관리하고 있습니다.각 라이브러리는 종속 프로젝트에 하위 모듈로 가져온 개별 리포입니다.개발 중에는 모든 종속 서브모듈의 최신 버전을 가져와야 하는 경우가 많습니다.
모든 git 서브모듈의 최신 변경은 어떻게 풀어야 합니까?
처음 체크아웃을 하는 경우 사용하셔야 합니다.--init
번째 first:::
git submodule update --init --recursive
git 1.8.2 이상의 경우 옵션--remote
브랜치의 에 대한 하기 위해 추가되었습니다.
git submodule update --recursive --remote
"기본값이" 를 "기본값이 아닌" 브랜치로 할 수 ..gitmodules
★★★★★★★★★★★★★★★★★」.git/config
파일(기본값은 origin/master이며, 이 경우 다른 답변도 일부 사용할 수 있습니다).
git 1.7.3 이상의 경우 사용할 수 있습니다(단, 아래의 내용은 아직 적용되는 업데이트에 대한 내용입니다).
git submodule update --recursive
또는 다음과 같이 입력합니다.
git pull --recurse-submodules
서브모듈을 현재 커밋이 아닌 최신 커밋으로 풀링하려면 repo가 가리키는 커밋을 수행합니다.
자세한 내용은 git-submodule(1)을 참조하십시오.
git pull --recurse-submodules --jobs=10
1.8.5에서 처음 배운 기능.
버그가 수정될 때까지 처음으로 실행해야 합니다.
git 서브 모듈업데이트 --init --submodule update
init 시 다음 명령어를 실행합니다.
git submodule update --init --recursive
git repo 디렉토리에서 가장 잘 작동합니다.
서브모듈을 포함한 최신의 모든 것을 가져옵니다.
설명된
git - the base command to perform any git command
submodule - Inspects, updates and manages submodules.
update - Update the registered submodules to match what the superproject
expects by cloning missing submodules and updating the working tree of the
submodules. The "updating" can be done in several ways depending on command
line options and the value of submodule.<name>.update configuration variable.
--init without the explicit init step if you do not intend to customize
any submodule locations.
--recursive is specified, this command will recurse into the registered
submodules, and update any nested submodules within.
그런 다음 실행할 수 있습니다.
git submodule update --recursive
git repo 디렉토리에서 가장 잘 작동합니다.
서브모듈을 포함한 최신의 모든 것을 가져옵니다.
주의: 이것은 2009년부터의 것으로, 그 때는 좋을지도 모르지만, 현재는 보다 좋은 옵션이 있습니다.
이걸 쓰죠.라고 합니다.git-pup
:
#!/bin/bash
# Exists to fully update the git repo that you are sitting in...
git pull && git submodule init && git submodule update && git submodule status
적절한 bin 디렉토리(/usr/local/bin)에 넣습니다.Windows 의 경우는, 구문을 수정하고, 동작시킬 필요가 있는 경우가 있습니다.
업데이트:
모든 서브모듈의 모든 HEAD를 끌어당기는 것에 대한 원저자의 코멘트에 대한 답변입니다.이것은 좋은 질문입니다.
나는 거의 확신해git
에는 내부적으로 이에 대한 명령어가 없습니다.그러기 위해서는 서브모듈의 HEAD가 실제로 무엇인지 식별해야 합니다. 수 .master
가장 최신의 지점 등
그 후 다음 작업을 수행하는 간단한 스크립트를 만듭니다.
- 합니다.
git submodule status
를 참조해 주세요.출력 라인의 첫 번째 문자가 이를 나타냅니다.하위 보고서가 수정된 경우 계속 진행하지 않을 수 있습니다. - 각 에 입력하고 "repo"를 실행합니다.
git checkout master && git pull
에러가 없는지 확인합니다. - 마지막으로 서브모듈의 현재 상태를 표시하기 위해 디스플레이를 사용자에게 인쇄하는 것이 좋습니다.모두 추가하고 커밋하도록 지시하는 것은 어떻습니까?
이 스타일은 실제로 git 서브모듈을 위해 설계된 것이 아닙니다.일반적으로 LibraryX는 버전 2.32로 업그레이드하라는 지시가 있을 때까지 그대로 있습니다.
이것은 어떤 의미에서는 설명한 스크립트로 하고 있는 작업이지만, 보다 자동적으로 실행할 수 있습니다.주의가 필요합니다!
업데이트 2:
Windows 플랫폼에 있는 경우 Python을 사용하여 스크립트를 구현하는 것이 좋습니다.이러한 영역에서는 Python이 매우 기능하기 때문입니다.unix/linux 를 사용하고 있는 경우는, bash 스크립트만을 추천합니다.
설명이 필요하신가요?댓글로 올려주세요.
헨리는 올바른 길을 가고 있다.그git submodule foreach
명령어는 임의의 셸 스크립트를 실행할 수 있습니다.최신 버전을 가져오는 두 가지 옵션은 다음과 같습니다.
git submodule foreach git pull origin master
또, 다음과 같이 합니다.
git submodule foreach /path/to/some/cool/script.sh
그러면 초기화된 모든 서브모듈이 반복되어 지정된 명령어가 실행됩니다.
Windows 에서는, 이하가 유효했습니다.
git submodule init
git submodule update
처음
클론 및 초기화 서브모듈
git clone git@github.com:speedovation/kiwi-resources.git resources
git submodule init
쉬다
개발 중에 서브모듈을 풀 및 업데이트하기만 하면 됩니다.
git pull --recurse-submodules && git submodule update --recursive
Git 하위 모듈을 오리진에서 최신 커밋으로 업데이트
git submodule foreach git pull origin master
바람직한 방법은 다음과 같습니다.
git submodule update --remote --merge
주의: 마지막 두 명령어의 동작은 동일합니다.
저는 git 2.24.03에서 .gitmodules에 정의되어 있는 리모트브런치의 최신 커밋을 갱신합니다.
git submodule update --recursive --init
git submodule update --recursive --remote
git 버전 2.24.3 (Apple Git-128)
주의사항:누가 그러던데git pull --recurse-submodules
is is is is is와 git submodule update --recursive --remote
내 ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★」git pull --recurse-submodules
는 .syslog modules에서 정의된 리모트브런치의 최신 커밋으로 갱신되지 않을 수 있습니다.
편집:
코멘트에서 (필프레오에 의해) 최신 버전이 필요하다고 지적되었습니다.최신 버전이어야 하는 중첩된 서브모듈이 있는 경우:
git submodule foreach --recursive git pull
-----다음의 오래된 코멘트-----
이게 공식적인 방법 아닌가요?
git submodule update --init
매번 쓰고 있어요.아직까지는 문제 없습니다.
편집:
다음 기능을 사용할 수 있습니다.
git submodule foreach --recursive git submodule update --init
모든 하위 모듈(예: 종속성)을 반복적으로 끌어옵니다.
서브모듈의 디폴트브런치는 다음과 같습니다. 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에서 동작하고 있는지는 모르겠지만, 그것이 당신이 찾고 있는 것입니다.
git submodule update --recursive
와 i i i i i i i i i i i i와 같이 .git pull
합니다.
git pull && git submodule update --recursive
위의 답변은 좋지만, 우리는 이것을 쉽게 하기 위해 git-hook을 사용했지만, git 2.14에서는 true로 설정하여 git 저장소로 풀할 때 서브모듈을 업데이트할 수 있도록 할 수 있습니다.
이 경우 브랜치에 있는 모든 서브모듈 변경이 푸시되는 부작용이 발생하지만 이미 필요한 경우 이 작업을 수행할 수 있습니다.
다음을 사용하여 수행할 수 있습니다.
git config submodule.recurse true
리모트로부터 각 서브모듈의 「최신」코드를 취득하는 것에 관한 기존의 회답에 근거해, 몇개의 점을 명확히 한다.
"latest"가 체크인된 서브모듈 포인터를 의미할 경우 반드시 다음을 사용합니다.
git submodule update --recursive
- or -
git pull --recurse-submodules --jobs=X
"latest"가 최신 메인 버전을 의미할 경우 다음과 같은 기능이 있습니다.
git submodule foreach "git checkout main && git pull"
안타깝게도 "--jobs" 옵션이 없으므로 병렬로 실행할 수 없습니다.병렬로 실행하는 가장 가까운 방법은 pfs python 코드를 사용하는 것입니다.
이 명령어를 자주 사용합니다.지금까지는 효과가 있습니다.
git pull
git submodule foreach --recursive git checkout master
git submodule foreach --recursive git pull
좀 더 빨리 했으면 좋겠다.
항독성 답변에서 알 수 있듯이, 간단한 것은git submodule foreach --recursive git pull
네, 그렇습니다.
프랜시스 베이컨의 회답 노트git pull --recurse-submodules
다를 수 있습니다.
자세한 옵션에서 어떤 일이 일어나고 있는지 테스트하여 확인할 수 있습니다.
git pull -v --recurse-submodules
하지만 그러기 위해서는 Git 2.40(2023년 1분기)이 필요합니다.
" 통과를 시도했습니다.git pull -v --recurse-submodules
(man)-v
이 문제는 Git 2.40(2023년 1분기)에서 수정되었습니다.
Sven Strickroth의 csware
commit 6f65f84 (2022년 12월 10일)를 참조하십시오().
(커밋 b3b9e5c에서 Junio C Hamano에 의해 병합, 2022년 12월 28일)
submodule
: 수락-v
update의 경우서명자: Sven Strickroth
a56771a 이후 (')
builtin/pull
: 서브모듈의 상세 설정을 존중한다", 2018-01-25, Git v2.17.0-rc0 -- 배치 #3에 나열된 병합),git pull -v --recurse-submodules
(man) "" ""는 다음을 전파합니다.-v
submodule 명령어로 변환합니다만, 후자의 명령어는 옵션을 인식할 수 없기 때문에, 토해냅니다.수정 옵션을 받아들이도록 가르칩니다.
git submodule update
(man)
더 이상 "구토"가 없습니다(IE. 사용법을 표시함).git submodule foreach [--quiet] [--recursive] [--] <command>
') 왜냐하면-v
에 대해 알 수 없는 옵션이었다.git submodule
.
Windows 2.6.3용 Git:
git submodule update --rebase --remote
리포의 최상위 레벨부터:
git submodule foreach git checkout develop
git submodule foreach git pull
그러면 모든 브랜치가 최신 개발 및 풀로 전환됩니다.
위의 가후아의 답변을 수정하여 이 작업을 수행했습니다.
git과 통합[alias]
...
부모 프로젝트에 이와 같은 것이 있는 경우.gitmodules
:
[submodule "opt/submodules/solarized"]
path = opt/submodules/solarized
url = git@github.com:altercation/solarized.git
[submodule "opt/submodules/intellij-colors-solarized"]
path = opt/submodules/intellij-colors-solarized
url = git@github.com:jkaving/intellij-colors-solarized.git
.gitconfig에 다음과 같은 것을 추가합니다.
[alias]
updatesubs = "!sh -c \"git submodule init && git submodule update && git submodule status\" "
그런 다음 하위 모듈을 업데이트하려면 다음을 수행합니다.
git updatesubs
지금 당신이 해야 할 일은 단순하다.git checkout
반드시 다음 글로벌Configuration을 사용하여 활성화 해 주세요.git config --global submodule.recurse true
서브모듈에 관계없이 모든 git 저장소에서 꺼낼 수 있는 명령줄을 다음에 나타냅니다.
ROOT=$(git rev-parse --show-toplevel 2> /dev/null)
find "$ROOT" -name .git -type d -execdir git pull -v ';'
top git 저장소에서 실행 중인 경우 대체가 가능합니다."$ROOT"
안으로.
.
비고: 너무 쉬운 방법은 아니지만 실행 가능하고 고유한 장점이 있습니다.
복제만 원하는 경우HEAD
저장소 수정 및 한정HEAD
(즉, "트렁크"를 체크하기 위해) 모든 서브모듈에서 다음 Lua 스크립트를 사용할 수 있습니다.경우에 따라서는 간단한 명령어git submodule update --init --recursive --remote --no-fetch --depth=1
회복 불능이 될 수 있다git
에러입니다.이 경우, 다음의 서브 디렉토리를 청소할 필요가 있습니다..git/modules
디렉토리 및 복제 서브모듈 수동 사용git clone --separate-git-dir
명령어를 입력합니다.유일한 복잡성은 URL과 경로를 찾는 것입니다..git
서브모듈 디렉토리 및 슈퍼프로젝트 트리의 서브모듈 경로.
비고: 이 스크립트는 다음 조건에 대해서만 테스트됩니다.https://github.com/boostorg/boost.git
저장소입니다.그 특징: 모든 서브모듈이 동일한 호스트에서 호스트되고,.gitmodules
에는 상대 URL만 포함되어 있습니다.
-- mkdir boost ; cd boost ; lua ../git-submodules-clone-HEAD.lua https://github.com/boostorg/boost.git .
local module_url = arg[1] or 'https://github.com/boostorg/boost.git'
local module = arg[2] or module_url:match('.+/([_%d%a]+)%.git')
local branch = arg[3] or 'master'
function execute(command)
print('# ' .. command)
return os.execute(command)
end
-- execute('rm -rf ' .. module)
if not execute('git clone --single-branch --branch master --depth=1 ' .. module_url .. ' ' .. module) then
io.stderr:write('can\'t clone repository from ' .. module_url .. ' to ' .. module .. '\n')
return 1
end
-- cd $module ; git submodule update --init --recursive --remote --no-fetch --depth=1
execute('mkdir -p ' .. module .. '/.git/modules')
assert(io.input(module .. '/.gitmodules'))
local lines = {}
for line in io.lines() do
table.insert(lines, line)
end
local submodule
local path
local submodule_url
for _, line in ipairs(lines) do
local submodule_ = line:match('^%[submodule %"([_%d%a]-)%"%]$')
if submodule_ then
submodule = submodule_
path = nil
submodule_url = nil
else
local path_ = line:match('^%s*path = (.+)$')
if path_ then
path = path_
else
submodule_url = line:match('^%s*url = (.+)$')
end
if submodule and path and submodule_url then
-- execute('rm -rf ' .. path)
local git_dir = module .. '/.git/modules/' .. path:match('^.-/(.+)$')
-- execute('rm -rf ' .. git_dir)
execute('mkdir -p $(dirname "' .. git_dir .. '")')
if not execute('git clone --depth=1 --single-branch --branch=' .. branch .. ' --separate-git-dir ' .. git_dir .. ' ' .. module_url .. '/' .. submodule_url .. ' ' .. module .. '/' .. path) then
io.stderr:write('can\'t clone submodule ' .. submodule .. '\n')
return 1
end
path = nil
submodule_url = nil
end
end
end
저는 이 간단한 셸 스크립트를 작업했습니다. 저에게 잘 맞습니다.
#!/bin/bash
#git init
git init
#git clone repo including submodules
git clone --recurse-submodules https://github.com/username/project.git
#change directory -repo
cd project
#update the remote ie tag/commits
git submodule update --remote
#add commit
git commit -a -m "commit in submodule"
#git push
git push -u origin
이걸 하려면 대본을 써야 할 것 같아요.솔직히 말하면 python을 설치하여os.walk
로.cd
적절한 명령어를 발행합니다.python 또는 배치 이외의 스크립트 언어를 사용하면 스크립트를 수정할 필요 없이 서브프로젝트를 쉽게 추가하거나 삭제할 수 있습니다.
언급URL : https://stackoverflow.com/questions/1030169/pull-latest-changes-for-all-git-submodules
'sourcecode' 카테고리의 다른 글
문자열을 분할하여 ToList()를 한 줄로 변환합니다. (0) | 2023.04.19 |
---|---|
C#의 대소문자를 무시하고 두 문자열 비교 (0) | 2023.04.19 |
홈브루 패키지가 설치되어 있는지 감지 (0) | 2023.04.19 |
python은 정렬된 목록을 가지고 있나요? (0) | 2023.04.19 |
Swift 3에서 상태 표시줄 스타일을 설정하는 방법 (0) | 2023.04.19 |