Home Explore Blog CI



git

1st chunk of `Documentation/git-merge.adoc`
45f37b2bc41ef5148afb5d6442aeeb675cd3f2289be8742d0000000100000fa0
git-merge(1)
============

NAME
----
git-merge - Join two or more development histories together


SYNOPSIS
--------
[synopsis]
git merge [-n] [--stat] [--no-commit] [--squash] [--[no-]edit]
	[--no-verify] [-s <strategy>] [-X <strategy-option>] [-S[<keyid>]]
	[--[no-]allow-unrelated-histories]
	[--[no-]rerere-autoupdate] [-m <msg>] [-F <file>]
	[--into-name <branch>] [<commit>...]
git merge (--continue | --abort | --quit)

DESCRIPTION
-----------
Incorporates changes from the named commits (since the time their
histories diverged from the current branch) into the current
branch.  This command is used by `git pull` to incorporate changes
from another repository and can be used by hand to merge changes
from one branch into another.

Assume the following history exists and the current branch is
`master`:

------------
	  A---B---C topic
	 /
    D---E---F---G master
------------

Then `git merge topic` will replay the changes made on the
`topic` branch since it diverged from `master` (i.e., `E`) until
its current commit (`C`) on top of `master`, and record the result
in a new commit along with the names of the two parent commits and
a log message from the user describing the changes. Before the operation,
`ORIG_HEAD` is set to the tip of the current branch (`C`).

------------
	  A---B---C topic
	 /         \
    D---E---F---G---H master
------------

A merge stops if there's a conflict that cannot be resolved
automatically or if `--no-commit` was provided when initiating the
merge. At that point you can run `git merge --abort` or `git merge
--continue`.

`git merge --abort` will abort the merge process and try to reconstruct
the pre-merge state. However, if there were uncommitted changes when the
merge started (and especially if those changes were further modified
after the merge was started), `git merge --abort` will in some cases be
unable to reconstruct the original (pre-merge) changes. Therefore:

WARNING: Running `git merge` with non-trivial uncommitted changes is
discouraged: while possible, it may leave you in a state that is hard to
back out of in the case of a conflict.

OPTIONS
-------
:git-merge: 1

include::merge-options.adoc[]

`-m <msg>`::
	Set the commit message to be used for the merge commit (in
	case one is created).
+
If `--log` is specified, a shortlog of the commits being merged
will be appended to the specified message.
+
The `git fmt-merge-msg` command can be
used to give a good default for automated `git merge`
invocations. The automated message can include the branch description.

`--into-name <branch>`::
	Prepare the default merge message as if merging to the branch
	_<branch>_, instead of the name of the real branch to which
	the merge is made.

`-F <file>`::
`--file=<file>`::
	Read the commit message to be used for the merge commit (in
	case one is created).
+
If `--log` is specified, a shortlog of the commits being merged
will be appended to the specified message.

include::rerere-options.adoc[]

`--overwrite-ignore`::
`--no-overwrite-ignore`::
	Silently overwrite ignored files from the merge result. This
	is the default behavior. Use `--no-overwrite-ignore` to abort.

`--abort`::
	Abort the current conflict resolution process, and
	try to reconstruct the pre-merge state. If an autostash entry is
	present, apply it to the worktree.
+
If there were uncommitted worktree changes present when the merge
started, `git merge --abort` will in some cases be unable to
reconstruct these changes. It is therefore recommended to always
commit or stash your changes before running `git merge`.
+
`git merge --abort` is equivalent to `git reset --merge` when
`MERGE_HEAD` is present unless `MERGE_AUTOSTASH` is also present in
which case `git merge --abort` applies the stash entry to the worktree
whereas `git reset --merge` will save the stashed changes in the stash
list.

`--quit`::
	Forget about the current merge in progress. Leave the index
	and the working tree as-is. If `MERGE_AUTOSTASH` is present, the
	stash entry

Title: Git Merge Command
Summary
The git merge command is used to join two or more development histories together, incorporating changes from named commits into the current branch, and can be used to resolve conflicts and manage merge processes.