Skip to content

Commit 30f2bad

Browse files
jrntrast
authored andcommitted
Documentation: emphasize when git merge terminates early
A merge-based operation in git can fail in two ways: one that stops before touching anything, or one that goes ahead and results in conflicts. As the 'git merge' manual explains: | A merge is always between the current `HEAD` and one or more | commits (usually, branch head or tag), and the index file must | match the tree of `HEAD` commit (i.e. the contents of the last commit) | when it starts out. Unfortunately, the placement of this sentence makes it easy to skip over, and its formulation leaves the important point, that any other attempted merge will be gracefully aborted, unspoken. So give this point its own section and expand upon it. Probably this could be simplified somewhat: after all, a change registered in the index is just a special kind of local uncommited change, so the second added paragraph is only a special case of the first. It seemed more helpful to be explicit here. Inspired by <http://gitster.livejournal.com/25801.html>. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Thomas Rast <trast@student.ethz.ch>
1 parent b40bb37 commit 30f2bad

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

Documentation/git-merge.txt

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,21 +67,32 @@ include::merge-options.txt[]
6767
<commit> obviously means you are trying an Octopus.
6868

6969

70+
PRE-MERGE CHECKS
71+
----------------
72+
73+
Before applying outside changes, you should get your own work in
74+
good shape and committed locally, so it will not be clobbered if
75+
there are conflicts. See also linkgit:git-stash[1].
76+
'git pull' and 'git merge' will stop without doing anything when
77+
local uncommitted changes overlap with files that 'git pull'/'git
78+
merge' may need to update.
79+
80+
To avoid recording unrelated changes in the merge commit,
81+
'git pull' and 'git merge' will also abort if there are any changes
82+
registered in the index relative to the `HEAD` commit. (One
83+
exception is when the changed index entries are in the state that
84+
would result from the merge already.)
85+
86+
If all named commits are already ancestors of `HEAD`, 'git merge'
87+
will exit early with the message "Already up-to-date."
88+
7089
HOW MERGE WORKS
7190
---------------
7291

7392
A merge is always between the current `HEAD` and one or more
74-
commits (usually, branch head or tag), and the index file must
75-
match the tree of `HEAD` commit (i.e. the contents of the last commit)
76-
when it starts out. In other words, `git diff --cached HEAD` must
77-
report no changes. (One exception is when the changed index
78-
entries are already in the same state that would result from
79-
the merge anyway.)
80-
81-
Three kinds of merge can happen:
93+
commits (usually a branch head or tag).
8294

83-
* The merged commit is already contained in `HEAD`. This is the
84-
simplest case, called "Already up-to-date."
95+
Two kinds of merge can happen:
8596

8697
* `HEAD` is already contained in the merged commit. This is the
8798
most common case especially when invoked from 'git pull':

0 commit comments

Comments
 (0)