Skip to content

Commit 77b3b79

Browse files
committed
Merge branch 'doc-style/for-next' of git://repo.or.cz/git/trast
* 'doc-style/for-next' of git://repo.or.cz/git/trast: Documentation: merge: use MERGE_HEAD to refer to the remote branch Documentation: simplify How Merge Works Documentation: merge: add a section about fast-forward Documentation: emphasize when git merge terminates early Documentation: merge: add an overview Documentation: merge: move merge strategy list to end Documentation: suggest `reset --merge` in How Merge Works section Documentation: merge: move configuration section to end Documentation: emphasise 'git shortlog' in its synopsis Documentation: show-files is now called git-ls-files Documentation: tiny git config manual tweaks Documentation: git gc packs refs by default now Conflicts: Documentation/config.txt
2 parents 7ecee33 + 3588cf9 commit 77b3b79

File tree

3 files changed

+102
-80
lines changed

3 files changed

+102
-80
lines changed

Documentation/git-ls-files.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ OPTIONS
141141

142142
Output
143143
------
144-
show files just outputs the filename unless '--stage' is specified in
144+
'git ls-files' just outputs the filenames unless '--stage' is specified in
145145
which case it outputs:
146146

147147
[<tag> ]<mode> <object> <stage> <file>

Documentation/git-merge.txt

Lines changed: 100 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,32 @@ SYNOPSIS
1515

1616
DESCRIPTION
1717
-----------
18-
Merges the history specified by <commit> into HEAD, optionally using a
19-
specific merge strategy.
18+
Incorporates changes from the named commits (since the time their
19+
histories diverged from the current branch) into the current
20+
branch. This command is used by 'git pull' to incorporate changes
21+
from another repository and can be used by hand to merge changes
22+
from one branch into another.
23+
24+
Assume the following history exists and the current branch is
25+
"`master`":
26+
27+
------------
28+
A---B---C topic
29+
/
30+
D---E---F---G master
31+
------------
32+
33+
Then "`git merge topic`" will replay the changes made on the
34+
`topic` branch since it diverged from `master` (i.e., `E`) until
35+
its current commit (`C`) on top of `master`, and record the result
36+
in a new commit along with the names of the two parent commits and
37+
a log message from the user describing the changes.
38+
39+
------------
40+
A---B---C topic
41+
/ \
42+
D---E---F---G---H master
43+
------------
2044

2145
The second syntax (<msg> `HEAD` <commit>...) is supported for
2246
historical reasons. Do not use it from the command line or in
@@ -47,88 +71,73 @@ include::merge-options.txt[]
4771
You need at least one <commit>. Specifying more than one
4872
<commit> obviously means you are trying an Octopus.
4973

50-
include::merge-strategies.txt[]
5174

75+
PRE-MERGE CHECKS
76+
----------------
5277

53-
If you tried a merge which resulted in complex conflicts and
54-
want to start over, you can recover with 'git reset'.
78+
Before applying outside changes, you should get your own work in
79+
good shape and committed locally, so it will not be clobbered if
80+
there are conflicts. See also linkgit:git-stash[1].
81+
'git pull' and 'git merge' will stop without doing anything when
82+
local uncommitted changes overlap with files that 'git pull'/'git
83+
merge' may need to update.
5584

56-
CONFIGURATION
57-
-------------
58-
include::merge-config.txt[]
85+
To avoid recording unrelated changes in the merge commit,
86+
'git pull' and 'git merge' will also abort if there are any changes
87+
registered in the index relative to the `HEAD` commit. (One
88+
exception is when the changed index entries are in the state that
89+
would result from the merge already.)
5990

60-
branch.<name>.mergeoptions::
61-
Sets default options for merging into branch <name>. The syntax and
62-
supported options are the same as those of 'git merge', but option
63-
values containing whitespace characters are currently not supported.
91+
If all named commits are already ancestors of `HEAD`, 'git merge'
92+
will exit early with the message "Already up-to-date."
6493

65-
HOW MERGE WORKS
66-
---------------
67-
68-
A merge is always between the current `HEAD` and one or more
69-
commits (usually, branch head or tag), and the index file must
70-
match the tree of `HEAD` commit (i.e. the contents of the last commit)
71-
when it starts out. In other words, `git diff --cached HEAD` must
72-
report no changes. (One exception is when the changed index
73-
entries are already in the same state that would result from
74-
the merge anyway.)
75-
76-
Three kinds of merge can happen:
77-
78-
* The merged commit is already contained in `HEAD`. This is the
79-
simplest case, called "Already up-to-date."
80-
81-
* `HEAD` is already contained in the merged commit. This is the
82-
most common case especially when invoked from 'git pull':
83-
you are tracking an upstream repository, have committed no local
84-
changes and now you want to update to a newer upstream revision.
85-
Your `HEAD` (and the index) is updated to point at the merged
86-
commit, without creating an extra merge commit. This is
87-
called "Fast-forward".
88-
89-
* Both the merged commit and `HEAD` are independent and must be
90-
tied together by a merge commit that has both of them as its parents.
91-
The rest of this section describes this "True merge" case.
92-
93-
The chosen merge strategy merges the two commits into a single
94-
new source tree.
95-
When things merge cleanly, this is what happens:
96-
97-
1. The results are updated both in the index file and in your
98-
working tree;
99-
2. Index file is written out as a tree;
100-
3. The tree gets committed; and
101-
4. The `HEAD` pointer gets advanced.
102-
103-
Because of 2., we require that the original state of the index
104-
file matches exactly the current `HEAD` commit; otherwise we
105-
will write out your local changes already registered in your
106-
index file along with the merge result, which is not good.
107-
Because 1. involves only those paths differing between your
108-
branch and the branch you are merging
109-
(which is typically a fraction of the whole tree), you can
110-
have local modifications in your working tree as long as they do
111-
not overlap with what the merge updates.
112-
113-
When there are conflicts, the following happens:
114-
115-
1. `HEAD` stays the same.
116-
117-
2. Cleanly merged paths are updated both in the index file and
118-
in your working tree.
94+
FAST-FORWARD MERGE
95+
------------------
96+
97+
Often the current branch head is an ancestor of the named commit.
98+
This is the most common case especially when invoked from 'git
99+
pull': you are tracking an upstream repository, you have committed
100+
no local changes, and now you want to update to a newer upstream
101+
revision. In this case, a new commit is not needed to store the
102+
combined history; instead, the `HEAD` (along with the index) is
103+
updated to point at the named commit, without creating an extra
104+
merge commit.
105+
106+
This behavior can be suppressed with the `--no-ff` option.
119107

120-
3. For conflicting paths, the index file records up to three
121-
versions; stage1 stores the version from the common ancestor,
122-
stage2 from `HEAD`, and stage3 from the other branch (you
108+
TRUE MERGE
109+
----------
110+
111+
Except in a fast-forward merge (see above), the branches to be
112+
merged must be tied together by a merge commit that has both of them
113+
as its parents.
114+
115+
A merged version reconciling the changes from all branches to be
116+
merged is committed, and your `HEAD`, index, and working tree are
117+
updated to it. It is possible to have modifications in the working
118+
tree as long as they do not overlap; the update will preserve them.
119+
120+
When it is not obvious how to reconcile the changes, the following
121+
happens:
122+
123+
1. The `HEAD` pointer stays the same.
124+
2. The `MERGE_HEAD` ref is set to point to the other branch head.
125+
3. Paths that merged cleanly are updated both in the index file and
126+
in your working tree.
127+
4. For conflicting paths, the index file records up to three
128+
versions: stage 1 stores the version from the common ancestor,
129+
stage 2 from `HEAD`, and stage 3 from `MERGE_HEAD` (you
123130
can inspect the stages with `git ls-files -u`). The working
124131
tree files contain the result of the "merge" program; i.e. 3-way
125-
merge results with familiar conflict markers `<<< === >>>`.
126-
127-
4. No other changes are done. In particular, the local
132+
merge results with familiar conflict markers `<<<` `===` `>>>`.
133+
5. No other changes are made. In particular, the local
128134
modifications you had before you started merge will stay the
129135
same and the index entries for them stay as they were,
130136
i.e. matching `HEAD`.
131137

138+
If you tried a merge which resulted in complex conflicts and
139+
want to start over, you can recover with `git reset --merge`.
140+
132141
HOW CONFLICTS ARE PRESENTED
133142
---------------------------
134143

@@ -211,15 +220,17 @@ You can work through the conflict with a number of tools:
211220
mergetool which will work you through the merge.
212221

213222
* Look at the diffs. `git diff` will show a three-way diff,
214-
highlighting changes from both the HEAD and their versions.
223+
highlighting changes from both the `HEAD` and `MERGE_HEAD`
224+
versions.
215225

216-
* Look at the diffs on their own. `git log --merge -p <path>`
217-
will show diffs first for the HEAD version and then
218-
their version.
226+
* Look at the diffs from each branch. `git log --merge -p <path>`
227+
will show diffs first for the `HEAD` version and then the
228+
`MERGE_HEAD` version.
219229

220230
* Look at the originals. `git show :1:filename` shows the
221-
common ancestor, `git show :2:filename` shows the HEAD
222-
version and `git show :3:filename` shows their version.
231+
common ancestor, `git show :2:filename` shows the `HEAD`
232+
version, and `git show :3:filename` shows the `MERGE_HEAD`
233+
version.
223234

224235

225236
EXAMPLES
@@ -254,6 +265,17 @@ changes into a merge commit. Small fixups like bumping
254265
release/version name would be acceptable.
255266

256267

268+
include::merge-strategies.txt[]
269+
270+
CONFIGURATION
271+
-------------
272+
include::merge-config.txt[]
273+
274+
branch.<name>.mergeoptions::
275+
Sets default options for merging into branch <name>. The syntax and
276+
supported options are the same as those of 'git merge', but option
277+
values containing whitespace characters are currently not supported.
278+
257279
SEE ALSO
258280
--------
259281
linkgit:git-fmt-merge-msg[1], linkgit:git-pull[1],

Documentation/git-shortlog.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ SYNOPSIS
99
--------
1010
[verse]
1111
git log --pretty=short | 'git shortlog' [-h] [-n] [-s] [-e] [-w]
12-
git shortlog [-n|--numbered] [-s|--summary] [-e|--email] [-w[<width>[,<indent1>[,<indent2>]]]] [<committish>...]
12+
'git shortlog' [-n|--numbered] [-s|--summary] [-e|--email] [-w[<width>[,<indent1>[,<indent2>]]]] [<committish>...]
1313

1414
DESCRIPTION
1515
-----------

0 commit comments

Comments
 (0)