From a4697bef459a6b74438afb7132e02d50156b9041 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 16 Aug 2013 02:00:02 +0200 Subject: merging branches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- using-git.texinfo | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'using-git.texinfo') diff --git a/using-git.texinfo b/using-git.texinfo index 2a952e8..a62fb0c 100644 --- a/using-git.texinfo +++ b/using-git.texinfo @@ -325,6 +325,7 @@ to the blessed repository. @menu * Workflow:: * Creating branches:: +* Merging branches:: @end menu @@ -390,6 +391,63 @@ git checkout BRANCH_NAME +@node Merging branches +@section Merging branches + +The merge a branch into another, switch +to one of them and pull the other: + +@example +git checkout MERGER +git pull . MERGEE +@end example + +In the default mode, @command{git pull . MERGEE} +is a short and fore a fetch and merge: + +@example +git fetch MERGEE && +git merge MERGEE +@end example + +If you two cannot be automatically merged, +you will you get a merge conflict. A case +where you will get merge conflicts is when +one of the branches as made a modification +where the other has change the indention, +so keep to a coding style from the start; +or both has edited the same lines. + +If you get a merge conflict, git will tell +you so, in which files there are conflicts, +and exit with the return code 1 to indicated +that the merge was not successful and human +intervention is required. If the merger +branch as a file with the line +@code{Hello world} and the mergee branch +as the line @code{hello world!}, the +file will contain: + +@example +<<<<<<< HEAD +Hello world +======= +wello world! +>>>>>>> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +@end example + +Where +@code{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} +is the lower case hexadecimnal represention of +the commit ID at the tip of the mergee branch, +which is a SHA-1 hash sum of the commit. + +After a merge conflict you will need to stage +the files and make a new commit. + + + + @node GNU Free Documentation License @appendix GNU Free Documentation License -- cgit v1.2.3-70-g09d2