1CG-MERGE(1) CG-MERGE(1)
2
3
4
6 cg-merge - merge a branch to the current branch
7
9 cg-merge [-n] [-b BASE_COMMIT] [-j] [--squash] [-v] [BRANCH_NAME]
10
11
13 Takes a parameter identifying the branch to be merged, defaulting to
14 origin.
15
16 This command merges all changes currently in the given branch to your
17 current branch. This can produce a merging commit on your branch
18 sticking the two branch together (so-called tree merge). However in
19 case there are no changes in your branch that wouldn't be in the remote
20 branch, no merge commit is done and commit pointer of your branch is
21 just updated to the last commit on the remote branch (so-called
22 fast-forward merge).
23
24 In case of conflicts being generated by the merge, you have to examine
25 the tree (cg-merge will tell you which files contain commits; the
26 commits are denoted by rcsmerge-like markers <<<<, ====, and >>>>) and
27 then do cg-commit(1) yourself. cg-commit(1) will know that you are
28 committing a merge and will record it properly.
29
30 Note that when you are merging remote branches, cg-merge(1) will use
31 them in the state they are currently at in your repository. If you want
32 to fetch the latest changes from the remote repository, use
33 cg-fetch(1). If you want to fetch the changes and then merge them to
34 your branch, use the command cg-update(1).
35
36 Also note that if you have local changes in your tree that you did not
37 commit, cg-merge will always preserve them when fast-forwarding. When
38 doing a tree merge, it will preserve them if they don't conflict with
39 the merged changes, and report an error otherwise. In short, it should
40 do the Right Thing (tm), never lose your local changes and never let
41 them mix up with the merge.
42
43
45 -b BASE_COMMIT
46 Parameter specifies the base commit for the merge. Otherwise,
47 the least common ancestor is automatically selected.
48
49 -j Join the current branch and BRANCH_NAME together. This makes
50 sense when the branches have no common history, meaning they are
51 actually not branches related at all as far as GIT is concerned.
52 Merging such branches might be a user error and you well may be
53 doing something you do not want; but equally likely, you may
54 actually WANT to join the projects together, which is what this
55 option does.
56
57 -n Parameter specifies that you want to have tree merge never
58 autocommitted, but want to review and commit it manually. This
59 will basically make cg-merge always behave like there were
60 conflicts during the merge.
61
62 --squash
63 "Squash" merge - condense all the to-be-merged commits to a
64 single merge commit. This means "throw away history of the
65 branch I'm merging", essentially like in CVS or SVN, with the
66 same problem - re-merging with that branch later will cause
67 trouble. This is not recommended unless you actually really want
68 to flatten the history of the merged branch, e.g. when merging
69 topical branches to your mainline (you want to have the logical
70 change you developed in a branch as a single "do it" commit
71 instead of a sequence of "do it I", "fix it", "do it II", "fix
72 it II", "fix it III" commits like you would get with a regular
73 merge).
74
75 -v Display more verbose output - most notably list all the files
76 touched by the merged changes.
77
78 -h, --help
79 Print usage summary.
80
81 --long-help
82 Print user manual. The same as found in cg-merge(1).
83
85 .git/hooks/merge-pre BRANCH BASE CURHEAD MERGEDHEAD MERGETYPE
86 If the file exists and is executable it will be executed right
87 before the merge itself happens. The merge is cancelled if the
88 script returns non-zero exit code.
89
90 · MERGETYPE is either "forward", "squash", or "tree".
91
92 .git/hooks/merge-post BRANCH BASE CURHEAD MERGEDHEAD MERGETYPE STATUS
93 If the file exists and is executable it will be executed after
94 the merge is done.
95
96 · MERGETYPE is either "forward", "squash", or "tree".
97
98 · For forward, the STATUS is always "ok", while for "squash"
99 and "tree" the STATUS can be "localchanges", "conflicts",
100 "nocommit", or "ok".
101
103 Copyright © Petr Baudis, 2005
104
105
107 cg-merge is part of cogito(7), a toolkit for managing git(7) trees.
108
109
110
111
112 12/11/2006 CG-MERGE(1)