2016-07-14 5 views
2

상황을 재현하려면 다음을 수행 할 수 있습니다. 난 당신이 git rebase parent child-1을 실행하면 git rebase 대 git rebase <upstream>

git checkout -b parent --track 
touch check.yml 
cat > check.yml <<EOL 
1 
2 
3 
EOL 
git add --all 
git commit -m "parent branch" 
git checkout -b child --track 
vim check.yml # Change 1 to 11 
git add --all 
git commit -m child 
git checkout parent 
vim check.yml # change 3 to 31 
git add --all 
git commit --amend 

이제 병합 충돌을 얻을 것이다하지만 git checkout child-1 && git rebase 경우는 충돌을받지 않습니다.

다음은 git 명령의 실행 결과입니다.

$:~/webroot/test-repo$ GIT_TRACE=1 git rebase parent child-1 
trace: exec: 'git-rebase' 'parent' 'child-1' 
trace: run_command: 'git-rebase' 'parent' 'child-1' 
trace: built-in: git 'rev-parse' '--parseopt' '--' 'parent' 'child-1' 
trace: built-in: git 'rev-parse' '--git-dir' 
trace: built-in: git 'rev-parse' '--is-bare-repository' 
trace: built-in: git 'rev-parse' '--show-toplevel' 
trace: built-in: git 'config' '--bool' 'rebase.stat' 
trace: built-in: git 'config' '--bool' 'rebase.autostash' 
trace: built-in: git 'config' '--bool' 'rebase.autosquash' 
trace: built-in: git 'rev-parse' '--verify' 'parent^0' 
trace: built-in: git 'rev-parse' '--verify' 'parent^0' 
trace: built-in: git 'show-ref' '--verify' '--quiet' '--' 'refs/heads/child-1' 
trace: built-in: git 'rev-parse' '-q' '--verify' 'refs/heads/child-1' 
trace: built-in: git 'rev-parse' '--verify' 'HEAD' 
trace: built-in: git 'update-index' '-q' '--ignore-submodules' '--refresh' 
trace: built-in: git 'diff-files' '--quiet' '--ignore-submodules' 
trace: built-in: git 'diff-index' '--cached' '--quiet' '--ignore-submodules' 'HEAD' '--' 
trace: built-in: git 'merge-base' 'd29fb1b0ab2eefba0f8ef13fd4e37d61acb9ee6f' '75d8979d743ba575de680fd04d517aa74e813819' 
First, rewinding head to replay your work on top of it... 
trace: built-in: git 'checkout' '-q' 'd29fb1b0ab2eefba0f8ef13fd4e37d61acb9ee6f^0' 
trace: built-in: git 'update-ref' 'ORIG_HEAD' '75d8979d743ba575de680fd04d517aa74e813819' 
trace: built-in: git 'format-patch' '-k' '--stdout' '--full-index' '--ignore-if-in-upstream' '--src-prefix=a/' '--dst-prefix=b/' '--no-renames' '--no-cover-letter' 'd29fb1b0ab2eefba0f8ef13fd4e37d61acb9ee6f..75d8979d743ba575de680fd04d517aa$ 
4e813819' 
trace: exec: 'git-am' '--rebasing' '--resolvemsg= 
When you have resolved this problem, run "git rebase --continue". 
If you prefer to skip this patch, run "git rebase --skip" instead. 
To check out the original branch and stop rebasing, run "git rebase --abort". 
' 
trace: run_command: 'git-am' '--rebasing' '--resolvemsg= 
When you have resolved this problem, run "git rebase --continue". 
If you prefer to skip this patch, run "git rebase --skip" instead. 
To check out the original branch and stop rebasing, run "git rebase --abort". 
' 
trace: built-in: git 'rev-parse' '--parseopt' '--' '--rebasing' '--resolvemsg= 
When you have resolved this problem, run "git rebase --continue". 
If you prefer to skip this patch, run "git rebase --skip" instead. 
To check out the original branch and stop rebasing, run "git rebase --abort". 
' 
trace: built-in: git 'rev-parse' '--git-dir' 
trace: built-in: git 'rev-parse' '--show-prefix' 
trace: built-in: git 'rev-parse' '--show-toplevel' 
trace: built-in: git 'var' 'GIT_COMMITTER_IDENT' 
trace: built-in: git 'rev-parse' '--verify' '-q' 'HEAD' 
trace: built-in: git 'config' '--bool' '--get' 'am.keepcr' 
trace: built-in: git 'mailsplit' '-d4' '-o/home/schuettm/webroot/test-repo/.git/rebase-apply' '-b' '--' 
trace: built-in: git 'update-index' '-q' '--refresh' 
trace: built-in: git 'diff-index' '--cached' '--name-only' 'HEAD' '--' 
trace: built-in: git 'cat-file' '-t' '5290c010a2c88dc29a019cb8f08ece9162a6482c' 
trace: built-in: git 'cat-file' 'commit' '5290c010a2c88dc29a019cb8f08ece9162a6482c' 
trace: built-in: git 'config' 'i18n.commitencoding' 
trace: built-in: git 'show' '-s' '--pretty=raw' '--encoding=UTF-8' '5290c010a2c88dc29a019cb8f08ece9162a6482c' '--' 
trace: built-in: git 'diff-tree' '--root' '--binary' '--full-index' '5290c010a2c88dc29a019cb8f08ece9162a6482c' 
Applying: parent 
trace: built-in: git 'apply' '--build-fake-ancestor' '/home/schuettm/webroot/test-repo/.git/rebase-apply/patch-merge-tmp-index' '/home/schuettm/webroot/test-repo/.git/rebase-apply/patch' 
trace: built-in: git 'write-tree' 
Using index info to reconstruct a base tree... 
trace: built-in: git 'diff-index' '--cached' '--diff-filter=AM' '--name-status' 'HEAD' 
trace: built-in: git 'apply' '--cached' 
trace: built-in: git 'write-tree' 
Falling back to patching base and 3-way merge... 
trace: built-in: git 'merge-recursive' '4b825dc642cb6eb9a060e54bf8d69288fbee4904' '--' 'HEAD' 'bf8853bde213ddd00cb31b3d22906cf746dcc2fd' 
Auto-merging check.yml 
CONFLICT (add/add): Merge conflict in check.yml 
trace: built-in: git 'rerere' 
Failed to merge in the changes. 
Patch failed at 0001 parent 
trace: built-in: git 'config' '--bool' 'advice.amworkdir' 
The copy of the patch that failed is found in: 
    /home/schuettm/webroot/test-repo/.git/rebase-apply/patch 

When you have resolved this problem, run "git rebase --continue". 
If you prefer to skip this patch, run "git rebase --skip" instead. 
To check out the original branch and stop rebasing, run "git rebase --abort". 

trace: built-in: git 'rev-parse' '--verify' '-q' 'HEAD' 

그것이 문제처럼 보이지만 당신이 그것을 응시하는 경우

$:~/webroot/test-repo$ GIT_TRACE=1 git rebase                                            
trace: exec: 'git-rebase' 
trace: run_command: 'git-rebase' 
trace: built-in: git 'rev-parse' '--parseopt' '--' 
trace: built-in: git 'rev-parse' '--git-dir' 
trace: built-in: git 'rev-parse' '--is-bare-repository' 
trace: built-in: git 'rev-parse' '--show-toplevel' 
trace: built-in: git 'config' '--bool' 'rebase.stat' 
trace: built-in: git 'config' '--bool' 'rebase.autostash' 
trace: built-in: git 'config' '--bool' 'rebase.autosquash' 
trace: built-in: git 'rev-parse' '--verify' 'refs/heads/parent^0' 
trace: built-in: git 'rev-parse' '--verify' 'refs/heads/parent^0' 
trace: built-in: git 'symbolic-ref' '-q' 'HEAD' 
trace: built-in: git 'rev-parse' '--verify' 'HEAD' 
trace: built-in: git 'merge-base' '--fork-point' 'refs/heads/parent' 'HEAD' 
trace: built-in: git 'rev-parse' '--verify' 'HEAD' 
trace: built-in: git 'update-index' '-q' '--ignore-submodules' '--refresh' 
trace: built-in: git 'diff-files' '--quiet' '--ignore-submodules' 
trace: built-in: git 'diff-index' '--cached' '--quiet' '--ignore-submodules' 'HEAD' '--' 
trace: built-in: git 'merge-base' 'd29fb1b0ab2eefba0f8ef13fd4e37d61acb9ee6f' '75d8979d743ba575de680fd04d517aa74e813819' 
First, rewinding head to replay your work on top of it... 
trace: built-in: git 'checkout' '-q' 'd29fb1b0ab2eefba0f8ef13fd4e37d61acb9ee6f^0' 
trace: built-in: git 'update-ref' 'ORIG_HEAD' '75d8979d743ba575de680fd04d517aa74e813819' 
trace: built-in: git 'format-patch' '-k' '--stdout' '--full-index' '--ignore-if-in-upstream' '--src-prefix=a/' '--dst-prefix=b/' '--no-renames' '--no-cover-letter' '5290c010a2c88dc29a019cb8f08ece9162a6482c..75d8979d743ba575de680fd04d517aa7 
4e813819' 
trace: exec: 'git-am' '--rebasing' '--resolvemsg= 
When you have resolved this problem, run "git rebase --continue". 
If you prefer to skip this patch, run "git rebase --skip" instead. 
To check out the original branch and stop rebasing, run "git rebase --abort". 
' 
trace: run_command: 'git-am' '--rebasing' '--resolvemsg= 
When you have resolved this problem, run "git rebase --continue". 
If you prefer to skip this patch, run "git rebase --skip" instead. 
To check out the original branch and stop rebasing, run "git rebase --abort". 
' 
trace: built-in: git 'rev-parse' '--parseopt' '--' '--rebasing' '--resolvemsg= 
When you have resolved this problem, run "git rebase --continue". 
If you prefer to skip this patch, run "git rebase --skip" instead. 
To check out the original branch and stop rebasing, run "git rebase --abort". 
' 
trace: built-in: git 'rev-parse' '--git-dir' 
trace: built-in: git 'rev-parse' '--show-prefix' 
trace: built-in: git 'rev-parse' '--show-toplevel' 
trace: built-in: git 'var' 'GIT_COMMITTER_IDENT' 
trace: built-in: git 'rev-parse' '--verify' '-q' 'HEAD' 
trace: built-in: git 'config' '--bool' '--get' 'am.keepcr' 
trace: built-in: git 'mailsplit' '-d4' '-o/home/schuettm/webroot/test-repo/.git/rebase-apply' '-b' '--' 
trace: built-in: git 'update-index' '-q' '--refresh' 
trace: built-in: git 'diff-index' '--cached' '--name-only' 'HEAD' '--' 
trace: built-in: git 'cat-file' '-t' '75d8979d743ba575de680fd04d517aa74e813819' 
trace: built-in: git 'cat-file' 'commit' '75d8979d743ba575de680fd04d517aa74e813819' 
trace: built-in: git 'config' 'i18n.commitencoding' 
trace: built-in: git 'show' '-s' '--pretty=raw' '--encoding=UTF-8' '75d8979d743ba575de680fd04d517aa74e813819' '--' 
trace: built-in: git 'diff-tree' '--root' '--binary' '--full-index' '75d8979d743ba575de680fd04d517aa74e813819' 
Applying: child 
trace: built-in: git 'write-tree' 
trace: built-in: git 'rev-parse' '--verify' '-q' 'HEAD' 
trace: built-in: git 'commit-tree' '4db00e2710f88742114576a8a7d5ee6875f433c3' '-p' 'd29fb1b0ab2eefba0f8ef13fd4e37d61acb9ee6f' 
trace: built-in: git 'update-ref' '-m' 'rebase: child' 'HEAD' 'f7d50b6e381e0894904bd122d13c5880f8583916' 
trace: built-in: git 'notes' 'copy' '--for-rewrite=rebase' 
trace: built-in: git 'rev-parse' 'HEAD' 
trace: built-in: git 'update-ref' '-m' 'rebase finished: refs/heads/child-1 onto d29fb1b0ab2eefba0f8ef13fd4e37d61acb9ee6f' 'refs/heads/child-1' 'f7d50b6e381e0894904bd122d13c5880f8583916' '75d8979d743ba575de680fd04d517aa74e813819' 
trace: built-in: git 'symbolic-ref' '-m' 'rebase finished: returning to refs/heads/child-1' 'HEAD' 'refs/heads/child-1' 
trace: built-in: git 'gc' '--auto' 

git rebase 그 사람 페이지에서 또한 도움을 위해 reflog를 사용하는 병합베이스를 결정하기 위해 git 'merge-base' '--fork-point' 'refs/heads/parent' 'HEAD'를 사용한다는 것입니다 그리고 그것이 수정안을 집어 들고 갈등으로 멈추지 않는 이유가 될 수 있습니다.

어떤 마법적인 주장이이 기능을 허용하는 후드 아래 git rebase으로 전달되고 있습니까?

자식 REBASE에 대한 매뉴얼 페이지 내가 잘못된 상류에 오류가 자식 설정으로 그들을 찾는 이후에 그 값을 대체 할 때 어떤 식 으로든 내부적으로 이전에 확장됩니다 내가 추측하고있어 그래서 branch.<name>.remotebranch.<name>.merge 그러나 사용하는 것을 말한다 내가 이해하지 못하는 것을 사용하십시오.

답변

1

정확합니다, 그것은 --fork-point 마술입니다. 이것은 실제로 documented입니다 : 지정되지 않은

> 상류 < 경우, 상류 지점에서 구성. < 이름 >. 원격 및 분기. < 이름이 > 인 경우 .merge 옵션이 사용되고 (자세한 내용은 git-config(1) 참조) --fork-point 옵션이 사용됩니다. 현재 어떤 지점에도 없거나 현재 분기에 업스트림이 구성되어 있지 않으면 rebase가 중단됩니다.

rebase 명령에 --fork-point을 수동으로 추가하여 동일한 효과를 얻을 수 있습니다.

동작이 --fork-point 인 것은 세계에서 가장 쉽게 설명 할 수 없으며 rebase 설명서는 the git merge-base documentation으로 연결됩니다. 그것은 좋은 다이어그램을 가지고 있지만 설명의 관점에서 여전히 많이 남아 있습니다. --fork-point이 reflogs에 의존

때문에, 그것은 단지 한 당신의 상류 지점의 reflog 키 정보를 보유으로 작동합니다. 일반적으로 이것은 90 일 (도달 가능한 커밋의 만료) 또는 30 일 (도달 할 수없는 커밋의 만료)입니다. 언급하면서이 does not make it any easier to describe. :-)의 의도 도움이 될 수 있습니다 : 업스트림 REBASE에서 회복에 도움을 의미하고, 그렇게 수행합니다. 그래도 난 내가 꽤 잘 매뉴얼 페이지를 읽었다로

+0

나는 정말 바보가 된 기분하고 있었다. 그러나 사용하고있는 자식 버전은 이것을 문서화하지 않습니다.더 나은 설명 주셔서 감사합니다! – mschuett

+0

잠시 동안 fork-point는 rebase가 전혀없는'git pull '에서 마술이었습니다. 그리고'git rebase'로 옮겨졌지만 문서화되지 않았습니다. Git의 전환 버전 중 하나가 있어야합니다 ... – torek

0

나는이 사실에 대해 더 많이 알고있는 사람에게이 사실을 공개 할 것입니다. 그러나 리베이스 (rebase)를 위해 호출되는 git-rebase.sh 스크립트를 읽은 후에 어떤 이유로도 이 마법없이 추가되었다는 것을 발견했습니다. 이는 git rebase을 args가없이 호출 할 때입니다. 따라서 git rebasegit rebase --fork-point parent-branch과 같습니다.