@@ -657,52 +657,41 @@ <h2 id="_how_merge_works">HOW MERGE WORKS</h2>
657657< div class ="sectionbody ">
658658< div class ="para "> < p > A merge is always between the current < tt > HEAD</ tt > and one or more
659659commits (usually, branch head or tag), and the index file must
660- exactly match the
661- tree of < tt > HEAD</ tt > commit (i.e. the contents of the last commit) when
662- it happens. In other words, < tt > git diff --cached HEAD</ tt > must
663- report no changes.</ p > </ div >
664- < div class ="admonitionblock ">
665- < table > < tr >
666- < td class ="icon ">
667- < div class ="title "> Note</ div >
668- </ td >
669- < td class ="content "> This is a bit of a lie. In certain special cases, your index is
670- allowed to be different from the tree of the < tt > HEAD</ tt > commit. The most
671- notable case is when your < tt > HEAD</ tt > commit is already ahead of what
672- is being merged, in which case your index can have arbitrary
673- differences from your < tt > HEAD</ tt > commit. Also, your index entries
674- may have differences from your < tt > HEAD</ tt > commit that match
675- the result of a trivial merge (e.g. you received the same patch
676- from an external source to produce the same result as what you are
677- merging). For example, if a path did not exist in the common
678- ancestor and your head commit but exists in the tree you are
679- merging into your repository, and if you already happen to have
680- that path exactly in your index, the merge does not have to
681- fail.</ td >
682- </ tr > </ table >
683- </ div >
684- < div class ="para "> < p > Otherwise, merge will refuse to do any harm to your repository
685- (that is, it may fetch the objects from remote, and it may even
686- update the local branch used to keep track of the remote branch
687- with < tt > git pull remote rbranch:lbranch</ tt > , but your working tree,
688- < tt > .git/HEAD</ tt > pointer and index file are left intact). In addition,
689- merge always sets < tt > .git/ORIG_HEAD</ tt > to the original state of HEAD so
690- a problematic merge can be removed by using < tt > git reset ORIG_HEAD</ tt > .</ p > </ div >
691- < div class ="para "> < p > You may have local modifications in the working tree files. In
692- other words, < em > git-diff</ em > is allowed to report changes.
693- However, the merge uses your working tree as the working area,
694- and in order to prevent the merge operation from losing such
695- changes, it makes sure that they do not interfere with the
696- merge. Those complex tables in read-tree documentation define
697- what it means for a path to "interfere with the merge". And if
698- your local modifications interfere with the merge, again, it
699- stops before touching anything.</ p > </ div >
700- < div class ="para "> < p > So in the above two "failed merge" case, you do not have to
701- worry about loss of data --- you simply were not ready to do
702- a merge, so no merge happened at all. You may want to finish
703- whatever you were in the middle of doing, and retry the same
704- pull after you are done and ready.</ p > </ div >
705- < div class ="para "> < p > When things cleanly merge, these things happen:</ p > </ div >
660+ match the tree of < tt > HEAD</ tt > commit (i.e. the contents of the last commit)
661+ when it starts out. In other words, < tt > git diff --cached HEAD</ tt > must
662+ report no changes. (One exception is when the changed index
663+ entries are already in the same state that would result from
664+ the merge anyway.)</ p > </ div >
665+ < div class ="para "> < p > Three kinds of merge can happen:</ p > </ div >
666+ < div class ="ilist "> < ul >
667+ < li >
668+ < p >
669+ The merged commit is already contained in < tt > HEAD</ tt > . This is the
670+ simplest case, called "Already up-to-date."
671+ </ p >
672+ </ li >
673+ < li >
674+ < p >
675+ < tt > HEAD</ tt > is already contained in the merged commit. This is the
676+ most common case especially when involved through < em > git pull</ em > :
677+ you are tracking an upstream repository, committed no local
678+ changes and now you want to update to a newer upstream revision.
679+ Your < tt > HEAD</ tt > (and the index) is updated to at point the merged
680+ commit, without creating an extra merge commit. This is
681+ called "Fast-forward".
682+ </ p >
683+ </ li >
684+ < li >
685+ < p >
686+ Both the merged commit and < tt > HEAD</ tt > are independent and must be
687+ tied together by a merge commit that has them both as its parents.
688+ The rest of this section describes this "True merge" case.
689+ </ p >
690+ </ li >
691+ </ ul > </ div >
692+ < div class ="para "> < p > The chosen merge strategy merges the two commits into a single
693+ new source tree.
694+ When things cleanly merge, these things happen:</ p > </ div >
706695< div class ="olist "> < ol >
707696< li >
708697< p >
@@ -773,15 +762,16 @@ <h2 id="_how_merge_works">HOW MERGE WORKS</h2>
773762< p >
774763Decide not to merge. The only clean-up you need are to reset
775764 the index file to the < tt > HEAD</ tt > commit to reverse 2. and to clean
776- up working tree changes made by 2. and 3.; < em > git-reset</ em > can
765+ up working tree changes made by 2. and 3.; < em > git-reset --hard </ em > can
777766 be used for this.
778767</ p >
779768</ li >
780769< li >
781770< p >
782771Resolve the conflicts. < tt > git diff</ tt > would report only the
783- conflicting paths because of the above 2. and 3. Edit the
784- working tree files into a desirable shape, < em > git-add</ em > or < em > git-rm</ em >
772+ conflicting paths because of the above 2. and 3.
773+ Edit the working tree files into a desirable shape
774+ (< em > git mergetool</ em > can ease this task), < em > git-add</ em > or < em > git-rm</ em >
785775 them, to make the index file contain what the merge result
786776 should be, and run < em > git-commit</ em > to commit the result.
787777</ p >
@@ -811,7 +801,7 @@ <h2 id="_git">GIT</h2>
811801</ div >
812802< div id ="footer ">
813803< div id ="footer-text ">
814- Last updated 2008-07-15 15:48:34 UTC
804+ Last updated 2008-07-20 01:23:33 UTC
815805</ div >
816806</ div >
817807</ body >
0 commit comments