내 다른 프로젝트 (B)와 일정량의 코드를 공유하는 큰 자식 저장소 (A)가 있습니다. 유지 보수를 쉽게하기 위해 공통 코드 (C)가있는 세 번째 저장소를 가지고 다음 git subtree
을 통해 사용하기로 결정했습니다.자식 하위 트리 내보내기 및 다시 가져 오기
나는 A의 모든 (폴더 "하위"의 공통 코드를 넣어)를 준비하고 내가 몇 커밋과 C를 가지고, 내가 넣어 싶어 이제
C를 만들 Detach (move) subdirectory into separate Git repository에 설명 된 절차를 사용 다시 A, 폴더 하위로. 하위 폴더에 대한 모든 커밋이 중복 된 경우에만 작업 한 http://www.kernel.org/pub/software/scm/git/docs/howto/using-merge-subtree.html에 설명 된 방법을 사용했습니다. 나는 이것에 대해별로 신경 쓰지 않았다. 그러나이 서브 디렉토리로 작업을 계속하는 방법을 모르겠다.
나는 git subtree push changes back to subtree project에 설명 된대로 난 그냥 하위 트리에 지점을 만들git subtree split --prefix sub -b split-branch
를 사용 내가 C로 밀어 원하는 A/하위에 추가 변경을했다. 이것은 약간의 시간이 걸리지 만 성공적으로 완료됩니다.
git checkout split-branch
git push remote-c master
을하는 것은 나에게
failed to push some refs to "remote-c"
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and merge the remote changes
hint: (e.g. 'git pull') before pushing again.
을 제공하지만 git pull remote-c master
가 이미 래요 - - 날짜.
이 상황을 어떻게 해결합니까?
EDIT1 : 작은 테스트 스크립트로 문제를 재현하려고했습니다. 이 스크립트를 실행 :
(cd testC; git init --bare)
(cd testA; git init)
cd testA
git remote add C ../testC
mkdir sub
echo subFile1 > sub/subFile1
echo subFile2 > sub/subFile2
git add sub
git commit -m "adding files"
echo FileA > fileA
echo FileB > fileB
git add fileA fileB
git commit -m "add root level files"
# extract subtree and push to C
git subtree split -P sub -b split-branch
git push C split-branch:master
# try to make an update in C
git checkout -b cmaster C/master
echo subFile2new > subFile2
git commit subFile2 -m "updated #2 in C"
git push
이 결과
To ../testC
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to '../testC'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. If you did not intend to push that branch, you may want to
hint: specify branches to push or set the 'push.default' configuration
hint: variable to 'current' or 'upstream' to push only the current branch.
내가하려는 일을 이해한다면,'git' 서브 모듈이 상수 서브 트리 병합/추출보다 나은 해결책이라고 생각합니다. – twalberg
나는 chit submodule을 사용하는 것보다는 CVS로 돌아가고 싶다 ;-) 나는 이것을 한번 시도했지만 여전히 악몽을 꾼다. – Frankie
FYI, http://codingkilledthecat.wordpress.com/2012/04/28/why-your-company-shouldnt-use-git-submodules/에서는 서브 모듈 관련 문제를 설명합니다. – Frankie