여기서 git rebase --onto
을 사용해야하며 범위를 지정해야합니다.
(git rebase
man page를 참조하십시오 토픽 브랜치가 다른 하나 개의 지점을 기반으로
이식하면 rebase --onto
를 사용하여, 후자의 지점에서 주제 분기를 포크 척
합니다.).
물론 bug10
브랜치를 legacy
브랜치 상단으로 옮길 것입니다. 원하는/원하지 않는 브랜치입니다.
그래서, 하나의 해결 방법은 그 후, 복제 된 REPO에 리베이스 병합 할 하는 것 그 지역에 (그것의 상단에있는 bug10
수정하여 복제의 repo에서 하나) '강화'legacy
지점 현재 legacy
지점 (수정하려는 경우 bug10
만 남음).
지금 :
는
- 이 (디스크 공간 제한으로 이어질 수 있습니다) 별도의 repo 모두 모두
- 는,이 패치를 정의하고
legacy
지점에 적용하는 공정과 동일을 포함, 그래서 다른 답변 (패치)은 유효합니다 (더 간단합니다).
- 이 방법에서 볼 수있는 유일한 이점은 원래의 repo에 해당 브랜치
legacy
을 푸시하기 전에 (bug10
커밋과 같은) 원하는 것을 리베이스 한 레거시 환경을 정의 할 수있는 기회입니다 (bug10
, 그 역사가 완전히 재 작성되었을 것이기 때문에!)
나는 그것이 단지 작동하는지보고 싶었다. 그래서 ... 그 접근법을 테스트 해보자.
(Git1.6.5.1 때문에 Start-Transcript
command의 파워 쉘 1.0 세션과 오래된 XP SP2에) 나는 내가 자식의 repo 디렉토리를 만들기 위해 더 이상하지 않아도 방법을 좋아한다
PS D:\> mkdir git
PS D:\> cd git
PS D:\git> mkdir tests
PS D:\git> cd tests
PS D:\git\tests> git init mainRepo
먼저 git init
!을 입력하십시오. Since 1.6.5는 (즉, "git init this
") 추가 인수를 주어 졌을 때
"git init
"는 디렉토리에 mkdir
/chdir
에 배웠습니다.
이것은 대단한 것입니다!
3 가지 목적으로 3 개의 파일을 만들어 보겠습니다.
(예를 위해, 나는 수정이 지점마다 별도의 파일로 유지됩니다 병합시 어떤 충돌을하거나 여기 리베이스.)
PS D:\git\tests> cd mainRepo
PS D:\git\tests\mainRepo> echo mainFile > mainFile.txt
PS D:\git\tests\mainRepo> echo contentToBeFixed > toBeFixedFile.txt
PS D:\git\tests\mainRepo> echo legacyContent > legacy.txt
PS D:\git\tests\mainRepo> git add -A
PS D:\git\tests\mainRepo> git ci -m "first commit"
PS D:\git\tests\mainRepo> echo firstMainEvol >> mainFile.txt
PS D:\git\tests\mainRepo> git ci -a -m "first evol, for making 1.0"
PS D:\git\tests\mainRepo> git tag -m "1.0 legacy content" 1.0
을이 시점에서, git log --graph --oneline --branches
반환 :
* b68c1f5 first evol, for making 1.0
* 93f9f7c first commit
"또 다른 우리가 태그 것이다, 커밋 확인의이
PS D:\git\tests\mainRepo> git co -b legacy
PS D:\git\tests\mainRepo> echo aFirstLegacyEvol >> legacy.txt
PS D:\git\tests\mainRepo> git ci -a -m "a first legacy evolution"
우리는 주인에게 돌려 legacy
분기를 구축하자 2.0 "(! 일부 버그 고정을 필요로하는 자료)
PS D:\git\tests\mainRepo> git co -b master
PS D:\git\tests\mainRepo> git co master
PS D:\git\tests\mainRepo> echo aMainEvol >> mainFile.txt
PS D:\git\tests\mainRepo> git ci -a -m "a main evol"
PS D:\git\tests\mainRepo> echo aSecondMainEvolFor2.0 >> mainFile.txt
PS D:\git\tests\mainRepo> git ci -a -m "a second evol for 2.0"
PS D:\git\tests\mainRepo> git tag -m "main 2.0 before bugfix" 2.0
우리는이 :
PS D:\git\tests\mainRepo> git co -b bug10
PS D:\git\tests\mainRepo> echo aFirstBug10Fix >> toBeFixedFile.txt
PS D:\git\tests\mainRepo> git ci -a -m "a first bug10 fix"
PS D:\git\tests\mainRepo> echo aSecondBug10Fix >> toBeFixedFile.txt
PS D:\git\tests\mainRepo> git ci -a -m "a second bug10 fix"
가의 추가하자 :
* e727105 a second evol for 2.0
* 473d44e a main evol
| * dbcc7aa a first legacy evolution
|/
* b68c1f5 first evol, for making 1.0
* 93f9f7c first commit
이제 우리는 bug10
버그 수정 지점을 본부에 대한 최종 커밋
PS D:\git\tests\mainRepo> git co master
PS D:\git\tests\mainRepo> echo anotherMainEvol >> mainFile.txt
PS D:\git\tests\mainRepo> git ci -a -m "another main evol"
우리의 주요 REPO의 6,510,403,210 최종 상태 :이 단계에서
* 55aac85 another main evol
| * 47e6ee1 a second bug10 fix
| * 8183707 a first bug10 fix
|/
* e727105 a second evol for 2.0
* 473d44e a main evol
| * dbcc7aa a first legacy evolution
|/
* b68c1f5 first evol, for making 1.0
* 93f9f7c first commit
, 나는 mainRepo에서 더 이상 조작을하지 않습니다. 나는 그것을 시험해보기 위해 복제 할 것입니다. 실패 할 경우 언제든지이 저장소로 돌아와 다시 복제 할 수 있습니다.
PS D:\git\tests\rebaseRepo> git co -b bug10 origin/bug10
PS D:\git\tests\rebaseRepo> git co -b legacy origin/legacy
(즉의 만 bug10을 리베이스 보자
첫 번째 복제는 우리의 우리는 우리의 복제의 repo에 mainRepo 가지 중 두 가지를 필요 git rebase --onto
PS D:\git\tests\mainRepo> cd ..
PS D:\git\tests> git clone mainRepo rebaseRepo
PS D:\git\tests> cd rebaseRepo
수행하기 위해, 실제로는 필수입니다 모두 2.0
태그 이후 HEAD
bug10
분기의 커밋입니다. :
PS D:\git\tests\rebaseRepo> git co bug10
PS D:\git\tests\rebaseRepo> git rebase --onto legacy 2.0
First, rewinding head to replay your work on top of it...
Applying: a first bug10 fix
Applying: a second bug10 fix
이 시점에서 bug10
은 legacy
위로 재생되었으며 나머지 중간 커밋은입니다.
이제 의 legacy
을 되풀이하여 bug10
브랜치 맨 위로 전달할 수 있습니다.
PS D:\git\tests\rebaseRepo> git co legacy
Switched to branch 'legacy'
PS D:\git\tests\rebaseRepo> git merge bug10
Updating dbcc7aa..cf02bfc
Fast forward
toBeFixedFile.txt | Bin 38 -> 104 bytes
1 files changed, 0 insertions(+), 0 deletions(-)
내용은 우리가 필요로 팔로우하세요 :
PS D:\git\tests\rebaseRepo> type legacy.txt
legacyContent
aFirstLegacyEvol
,536,913을 63,210
012,374,849,678,831,
그렇습니다.
아이디어는 여전히이되는, 원래의 repo에 그 '강화'legacy
분기를 당겨하는 것입니다 그 bug10
변경 (즉, 여전히 2.0
태그에서 시작, 그리고 우리가에서 rebaseRepo
.
에했던 것처럼 어디서든 재생 복제 된 Repo, origin/legacy
지점을 추적하기 위해 legacy
지점을 원격 소스 : rebaseRepo
으로 병합합니다.이 원래의 repo에서
PS D:\git\tests\rebaseRepo> cd ..
PS D:\git\tests> git clone mainRepo finalRepo
PS D:\git\tests> cd finalRepo
PS D:\git\tests\finalRepo> git co -b legacy origin/legacy
, 내가 원격으로
rebaseRepo
을 선언하고 그 가지를 가져옵니다 (난 단지 내가 다른 실험이해야 할 일을했을 경우에 mainRepo의 상태 엉망, 그것을 복제).
PS D:\git\tests\finalRepo> git remote add rebasedRepo D:/git/tests/rebaseRepo
PS D:\git\tests\finalRepo> type D:\git\tests\finalRepo\.git\config
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = D:/git/tests/mainRepo
[branch "master"]
remote = origin
merge = refs/heads/master
[branch "legacy"]
remote = origin
merge = refs/heads/legacy
[remote "rebasedRepo"]
url = D:/git/tests/rebaseRepo
fetch = +refs/heads/*:refs/remotes/rebasedRepo/*
PS D:\git\tests\finalRepo> git fetch rebasedRepo
remote: Counting objects: 8, done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 6 (delta 3), reused 0 (delta 0)
Unpacking objects: 100% (6/6), done.
From D:/git/tests/rebaseRepo
* [new branch] bug10 -> rebasedRepo/bug10
* [new branch] legacy -> rebasedRepo/legacy
* [new branch] master -> rebasedRepo/master
우리는 지금 bug10
을 건드리지 않고 legacy
를 업데이트 할 수 있습니다
PS D:\git\tests\finalRepo> git merge rebasedRepo/legacy
Updating dbcc7aa..4919b68
Fast forward
toBeFixedFile.txt | Bin 38 -> 104 bytes
1 files changed, 0 insertions(+), 0 deletions(-)
당신은 과정에게 새로운 bug10
커밋 오래된 legacy
의 상단에 재생해야 할 때마다 원하는만큼 시간을 반복 할 수 있습니다 분기, 모든 중간 커밋을 포함하지 않고.
@Priyank : 동의합니다. 패치가 더 간단합니다. 하지만 제가 설명하는 방법은 복잡하지 않습니다. 그것은 당신이 repo를 복제 할 수 있고 당신이 거기서 밀고 나가는 것이 아니라면, 당신이 원하는 자식 작업을 쉽게 할 수 있다는 것을 보여줍니다. – VonC