GIT-MERGE(1)
โจ NAME โจ
git-merge โ Join two or more development histories together โ and yes bestie, this is the git-merge page from the Git Manual ๐.
๐ซถ SYNOPSIS ๐ซถ
git merge [-n] [--stat] [--compact-summary] [--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 ๐ฆ
Okay so what it does: it takes the changes from the named commits โ like, from back when their histories split off from your current branch โ and incorporates them into the current branch. git pull uses this command to incorporate changes from another repository, and you can also run it by hand to merge changes from one branch into another. Slay ๐
.
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 (G). Iconic behavior, honestly ๐.
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 โจ
okay bestie, this is the options menu and itโs lowkey iconic โ itโs giving โyou can control basically everythingโ energy ๐ no cap, every flag matters here.
--commit,--no-commitโ Do the merge and commit the result. This option can be used to override--no-commit.
With --no-commit, perform the merge and stop just before creating a merge commit, so you get a chance to inspect and further tweak the merge result before committing.
Note that fast-forward updates do not create a merge commit and therefore there is no way to stop those merges with --no-commit. Thus, if you want to ensure your branch is not changed or updated by the merge command, use --no-ff with --no-commit.
--edit,-e,--no-editโ Invoke an editor before committing a successful mechanical merge to further edit the auto-generated merge message, so you can explain and justify the merge. The--no-editoption can be used to accept the auto-generated message โ this is generally discouraged, fr fr. The--edit(or-e) option is still useful if you are giving a draft message with the-moption from the command line and want to edit it in the editor.
Older scripts may depend on the historical behaviour of not allowing the user to edit the merge log message. They will see an editor opened when they run git merge. To make it easier to adjust such scripts to the updated behaviour, the environment variable GIT_MERGE_AUTOEDIT can be set to no at the beginning of them.
--cleanup=<mode>โ This option determines how the merge message will be cleaned up before committing. Seegit-commit(1)for more details. In addition, if the<mode>is given a value ofscissors,scissorswill be appended toMERGE_MSGbefore being passed on to the commit machinery in the case of a merge conflict.--ff,--no-ff,--ff-onlyโ Specifies how a merge is handled when the merged-in history is already a descendant of the current history.--ffis the default unless merging an annotated (and possibly signed) tag that is not stored in its natural place in therefs/tags/hierarchy, in which case--no-ffis assumed.
With --ff, when possible resolve the merge as a fast-forward โ only update the branch pointer to match the merged branch; do not create a merge commit. When not possible (when the merged-in history is not a descendant of the current history), create a merge commit.
With --no-ff, create a merge commit in all cases, even when the merge could instead be resolved as a fast-forward.
With --ff-only, resolve the merge as a fast-forward when possible. When not possible, refuse to merge and exit with a non-zero status. No merge for you, bestie.
-S[<key-id>],--gpg-sign[=<key-id>],--no-gpg-signโ GPG-sign the resulting merge commit. The<key-id>argument is optional and defaults to the committer identity; if specified, it must be stuck to the option without a space.--no-gpg-signis useful to countermand bothcommit.gpgSignconfiguration variable, and earlier--gpg-sign.--log[=<n>],--no-logโ In addition to branch names, populate the log message with one-line descriptions from at most<n>actual commits that are being merged. See alsogit-fmt-merge-msg(1).
With --no-log, do not list one-line descriptions from the actual commits being merged.
--signoff,--no-signoffโ Add aSigned-off-bytrailer by the committer at the end of the commit log message. The meaning of a signoff depends on the project to which youโre committing. For example, it may certify that the committer has the rights to submit the work under the projectโs license or agrees to some contributor representation, such as a Developer Certificate of Origin. (Seehttps://developercertificate.orgfor the one used by the Linux kernel and Git projects.) Consult the documentation or leadership of the project to which youโre contributing to understand how the signoffs are used in that project.
The --no-signoff option can be used to countermand an earlier --signoff option on the command line.
Git does not (and will not) have a configuration variable to enable the --signoff command line option by default; see the commit.signoff entry in gitfaq(7) for more details.
--stat,-n,--no-statโ Show a diffstat at the end of the merge. The diffstat is also controlled by the configuration optionmerge.stat.
With -n or --no-stat, do not show a diffstat at the end of the merge.
--compact-summaryโ Show a compact-summary at the end of the merge.--squash,--no-squashโ Produce the working tree and index state as if a real merge happened (except for the merge information), but do not actually make a commit, move theHEAD, or record$GIT_DIR/MERGE_HEAD(to cause the nextgit commitcommand to create a merge commit). This allows you to create a single commit on top of the current branch whose effect is the same as merging another branch (or more in case of an octopus).
With --no-squash, perform the merge and commit the result. This option can be used to override --squash.
With --squash, --commit is not allowed, and will fail. periodt.
--verify,--no-verifyโ By default, thepre-mergeandcommit-msghooks are run. When--no-verifyis given, these are bypassed. See alsogithooks(5).-s <strategy>,--strategy=<strategy>โ Use the given merge strategy; can be supplied more than once to specify them in the order they should be tried. If there is no-soption, a built-in list of strategies is used instead (ortwhen merging a single head,octopusotherwise).-X <option>,--strategy-option=<option>โ Pass merge strategy specific option through to the merge strategy.--verify-signatures,--no-verify-signaturesโ Verify that the tip commit of the side branch being merged is signed with a valid key, i.e. a key that has a validuid: in the default trust model, this means the signing key has been signed by a trusted key. If the tip commit of the side branch is not signed with a valid key, the merge is aborted. Vibe check failed, no merge.--summary,--no-summaryโ Synonyms to--statand--no-stat; these are deprecated and will be removed in the future. so donโt get too attached, bestie.-q,--quietโ Operate quietly. Implies--no-progress.-v,--verboseโ Be verbose.--progress,--no-progressโ Turn progress on/off explicitly. If neither is specified, progress is shown if standard error is connected to a terminal. Note that not all merge strategies may support progress reporting.--autostash,--no-autostashโ Automatically create a temporary stash entry before the operation begins, record it in the refMERGE_AUTOSTASHand apply it after the operation ends. This means that you can run the operation on a dirty worktree. However, use with care: the final stash application after a successful merge might result in non-trivial conflicts. Itโs giving convenient but spicy.--allow-unrelated-historiesโ By default,git mergecommand refuses to merge histories that do not share a common ancestor. This option can be used to override this safety when merging histories of two projects that started their lives independently. As that is a very rare occasion, no configuration variable to enable this by default exists or will be added.-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.
--rerere-autoupdate,--no-rerere-autoupdateโ After the rerere mechanism reuses a recorded resolution on the current conflict to update the files in the working tree, allow it to also update the index with the result of resolution.--no-rerere-autoupdateis a good way to double-check whatgit-rerere(1)did and catch potential mismerges, before committing the result to the index with a separategit-add(1). bestie, double-checking is self-care.--overwrite-ignore,--no-overwrite-ignoreโ Silently overwrite ignored files from the merge result. This is the default behavior. Use--no-overwrite-ignoreto 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. fr fr, commit or stash first.
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. IfMERGE_AUTOSTASHis present, the stash entry will be saved to the stash list.--continueโ After agit mergestops due to conflicts you can conclude the merge by runninggit merge --continue(see "HOW TO RESOLVE CONFLICTS" section below).<commit>...โ Commits, usually other branch heads, to merge into our branch. Specifying more than one commit will create a merge with more than two parents (affectionately called an Octopus merge). ๐
If no commit is given from the command line, merge the remote-tracking branches that the current branch is configured to use as its upstream. See also the configuration section of this manual page.
When FETCH_HEAD (and no other commit) is specified, the branches recorded in the .git/FETCH_HEAD file by the previous invocation of git fetch for merging are merged to the current branch.
โจ PRE-MERGE CHECKS โจ
okay bestie, before you go applying anyone else's changes on top of your stuff, get your own work into good shape and committed locally โ that way it literally cannot get clobbered if conflicts happen. see also git-stash(1). git pull and git merge will just stop and do nothing at all when your local uncommitted changes overlap with the files that git pull/git merge might need to update. no vibes, no merge, just a stop. ๐
and to avoid recording unrelated changes in the merge commit, git pull and git merge will also abort if there are any changes registered in the index relative to the HEAD commit. (special narrow exceptions to this rule may exist depending on which merge strategy is in use, but generally? the index must match HEAD, periodt.)
if all the named commits are already ancestors of HEAD, git merge exits early with the message:
Already up to date.
like it's not even mad, it's just done. ๐
๐โโ๏ธ FAST-FORWARD MERGE ๐
so often the current branch head is an ancestor of the named commit. this is the most common case, especially when it's invoked from git pull: you're tracking an upstream repo, you haven't committed any local changes, and now you wanna update to a newer upstream revision. in this case a new commit is not needed to store the combined history โ instead, the HEAD (along with the index) just gets updated to point at the named commit, no extra merge commit required. slay, zero drama. โจ
this behavior can be suppressed with the --no-ff option. (she can be stopped, bestie.)
๐ TRUE MERGE ๐
except in a fast-forward merge (peep the section above โจ), the branches being merged have to be tied together by a merge commit that has both of them as its parents. that's the whole point.
a merged version reconciling the changes from all the branches being merged gets committed, and your HEAD, index, and working tree are all updated to it. and yes โ it is possible to have modifications in the working tree as long as they don't overlap; the update will preserve them. we love a considerate merge. ๐ซถ
when it is not obvious how to reconcile the changes, here's what goes down:
- The
HEADpointer stays the same. - The
MERGE_HEADref is set to point to the other branch head. - Paths that merged cleanly are updated both in the index file and in your working tree.
- For conflicting paths, the index file records up to three versions: stage 1 stores the version from the common ancestor, stage 2 from
HEAD, and stage 3 fromMERGE_HEAD(you can inspect the stages withgit ls-files -u). The working tree files contain the result of the merge operation; i.e. 3-way merge results with those familiar conflict markers<<< === >>>. - A ref named
AUTO_MERGEis written, pointing to a tree corresponding to the current content of the working tree (including conflict markers for textual conflicts). note that this ref is only written when theortmerge strategy is used (the default). iykyk ๐ง - No other changes are made. In particular, the local modifications you had before you started the merge will stay the same and the index entries for them stay as they were, i.e. matching
HEAD.
if you tried a merge and it resulted in complex conflicts and you just wanna start over โ breathe, it's fine โ you can recover with git merge --abort. ๐
๐ MERGING TAG ๐
when you're merging an annotated (and possibly signed) tag, Git always creates a merge commit even if a fast-forward merge is possible, and the commit message template is prepared with the tag message. additionally, if the tag is signed, the signature check is reported as a comment in the message template. see also git-tag(1).
but when you just want to integrate with the work leading to the commit that happens to be tagged โ like, say, synchronizing with an upstream release point โ you might not want to make an unnecessary merge commit. iconic of you, honestly.
in such a case you can "unwrap" the tag yourself before feeding it to git merge, or pass --ff-only when you don't have any work of your own. e.g.
git fetch origin
git merge v1.2.3^0
git merge --ff-only v1.2.3
๐ญ HOW CONFLICTS ARE PRESENTED ๐ญ
during a merge, the working tree files get updated to reflect the result of the merge. among the changes made to the common ancestor's version, non-overlapping ones โ that is, you changed an area of the file while the other side left that area intact, or vice versa โ are incorporated in the final result verbatim. but when both sides made changes to the same area, Git cannot randomly pick one side over the other, and asks you to resolve it by leaving what both sides did to that area. it's giving "you two figure this out". ๐
by default, Git uses the same style as the one used by the merge program from the RCS suite to present such a conflicted hunk, like this:
Here are lines that are either unchanged from the common
ancestor, or cleanly resolved because only one side changed,
or cleanly resolved because both sides changed the same way.
<<<<<<< yours:sample.txt
Conflict resolution is hard;
let's go shopping.
=======
Git makes conflict resolution easy.
>>>>>>> theirs:sample.txt
And here is another line that is cleanly resolved or unmodified.
the area where a pair of conflicting changes happened is marked with markers <<<<<<<, =======, and >>>>>>>. the part before the ======= is typically your side, and the part afterwards is typically their side. (yes, "typically" โ don't come for me.) ๐ธ
the default format does not show what the original said in the conflicting area. you cannot tell how many lines are deleted and replaced with Barbie's remark on your side. the only thing you can tell is that your side wants to say it is hard and you'd prefer to go shopping, while the other side wants to claim it is easy. literally two different vibes in one file. ๐
an alternative style can be used by setting the merge.conflictStyle configuration variable to either diff3 or zdiff3. in diff3 style, the above conflict may look like this:
Here are lines that are either unchanged from the common
ancestor, or cleanly resolved because only one side changed,
<<<<<<< yours:sample.txt
or cleanly resolved because both sides changed the same way.
Conflict resolution is hard;
let's go shopping.
||||||| base:sample.txt
or cleanly resolved because both sides changed identically.
Conflict resolution is hard.
=======
or cleanly resolved because both sides changed the same way.
Git makes conflict resolution easy.
>>>>>>> theirs:sample.txt
And here is another line that is cleanly resolved or unmodified.
while in zdiff3 style, it may look like this:
Here are lines that are either unchanged from the common
ancestor, or cleanly resolved because only one side changed,
or cleanly resolved because both sides changed the same way.
<<<<<<< yours:sample.txt
Conflict resolution is hard;
let's go shopping.
||||||| base:sample.txt
or cleanly resolved because both sides changed identically.
Conflict resolution is hard.
=======
Git makes conflict resolution easy.
>>>>>>> theirs:sample.txt
And here is another line that is cleanly resolved or unmodified.
in addition to the <<<<<<<, =======, and >>>>>>> markers, it uses another ||||||| marker that is followed by the original text. you can tell that the original just stated a fact, and your side simply gave in to that statement and gave up, while the other side tried to have a more positive attitude. (ngl relatable.) you can sometimes come up with a better resolution by viewing the original. ๐
๐ ๏ธ HOW TO RESOLVE CONFLICTS ๐ ๏ธ
after seeing a conflict, you can do two things:
- decide not to merge. the only clean-ups you need are to reset the index file to the
HEADcommit to reverse 2. and to clean up working tree changes made by 2. and 3.;git merge --abortcan be used for this. - resolve the conflicts. Git will mark the conflicts in the working tree. edit the files into shape and
git addthem to the index. usegit commitorgit merge --continueto seal the deal. the latter command checks whether there is a (interrupted) merge in progress before callinggit commit. ๐ซถ
you can work through the conflict with a number of tools:
- use a mergetool.
git mergetoolto launch a graphical mergetool which will work through the merge with you. teamwork, bestie โจ - look at the diffs.
git diffwill show a three-way diff, highlighting changes from both theHEADandMERGE_HEADversions.git diff AUTO_MERGEwill show what changes you've made so far to resolve textual conflicts. - look at the diffs from each branch.
git log --merge -p <path>will show diffs first for theHEADversion and then theMERGE_HEADversion. - look at the originals.
git show :1:filenameshows the common ancestor,git show :2:filenameshows theHEADversion, andgit show :3:filenameshows theMERGE_HEADversion. the numbers are the stages, iykyk ๐
๐ EXAMPLES ๐
- merge branches
fixesandenhancementson top of the current branch, making an octopus merge:
$ git merge fixes enhancements
- merge branch
obsoleteinto the current branch, using theoursmerge strategy:
$ git merge -s ours obsolete
- merge branch
maintinto the current branch, but do not make a new commit automatically:
$ git merge --no-commit maint
this can be used when you want to include further changes to the merge, or want to write your own merge commit message.
you should refrain from abusing this option to sneak substantial changes into a merge commit. small fixups like bumping a release/version name would be acceptable. like, keep it cute, don't make it a whole thing. ๐
๐ MERGE STRATEGIES ๐
Okay bestie, so the merge mechanism (that's git merge and git pull) lets you pick which backend merge strategy does the actual work, and you choose it with the -s option. Some strategies are extra and take their own options too โ you pass those by handing -X<option> arguments to git merge and/or git pull. Slay. ๐
๐ง ort
This is THE default merge strategy when you're pulling or merging one branch. Periodt. It can only resolve two heads, using a 3-way merge algorithm. When there's more than one common ancestor that could be used for the 3-way merge, it creates a merged tree of the common ancestors and uses that as the reference tree for the 3-way merge. Ngl, this has been reported to result in fewer merge conflicts without causing mismerges โ based on tests done on actual merge commits taken from Linux 2.6 kernel development history. Iconic behavior honestly. โจ
On top of that, this strategy can detect and handle merges involving renames. It does not, however, make use of detected copies. And the name? It's an acronym โ "Ostensibly Recursive's Twin" โ which came from the fact that it was written as a replacement for the previous default algorithm, recursive. The lore is real. ๐
Now, when the path is a submodule: if the submodule commit used on one side of the merge is a descendant of the submodule commit used on the other side of the merge, Git attempts to fast-forward to the descendant. Otherwise, Git treats this case as a conflict, and suggests as a resolution a submodule commit that is a descendant of the conflicting ones โ if one exists. ๐ซถ
The ort strategy can take the following options:
oursโ forces conflicting hunks to be auto-resolved cleanly by favoring our version. Changes from the other tree that don't conflict with our side still show up in the merge result. For a binary file, the entire contents are taken from our side.
Do not confuse this with the ours merge strategy, which doesn't even look at what the other tree contains at all. That one discards everything the other tree did and declares our history contains all that happened in it. Different vibes entirely ๐
theirsโ the opposite ofours. And note: unlikeours, there is notheirsmerge strategy to confuse this merge option with. So you can't mix them up. Convenient โจignore-space-change,ignore-all-space,ignore-space-at-eol,ignore-cr-at-eolโ treats lines with the indicated type of whitespace change as unchanged for the sake of a three-way merge. Whitespace changes mixed with other changes to a line are not ignored. See alsogit-diff(1)-b,-w,--ignore-space-at-eol, and--ignore-cr-at-eol.- If their version only introduces whitespace changes to a line, our version is used;
- If our version introduces whitespace changes but their version includes a substantial change, their version is used;
- Otherwise, the merge proceeds in the usual way.
renormalizeโ runs a virtual check-out and check-in of all three stages of any file which needs a three-way merge. This option is meant to be used when merging branches with different clean filters or end-of-line normalization rules. See "Merging branches with differing checkin/checkout attributes" ingitattributes(5)for the details. ๐no-renormalizeโ disables therenormalizeoption. This overrides themerge.renormalizeconfiguration variable.find-renames[=<n>]โ turns on rename detection, optionally setting the similarity threshold. This is the default. It overrides themerge.renamesconfiguration variable. See alsogit-diff(1)--find-renames.rename-threshold=<n>โ a deprecated synonym forfind-renames=<n>. Old. Vintage. Respectfully retired. ๐ฐ๏ธno-renamesโ turns off rename detection. This overrides themerge.renamesconfiguration variable. See alsogit-diff(1)--no-renames.histogramโ a deprecated synonym fordiff-algorithm=histogram.patienceโ a deprecated synonym fordiff-algorithm=patience.diff-algorithm=(histogram|minimal|myers|patience)โ use a different diff algorithm while merging, which can help avoid mismerges that occur because of unimportant matching lines (like braces from distinct functions, the classic menace ๐ญ). See alsogit-diff(1)--diff-algorithm. Heads up:ortdefaults todiff-algorithm=histogram, while regular diffs currently default to thediff.algorithmconfig setting.subtree[=<path>]โ a more advanced form of thesubtreestrategy. The strategy guesses how two trees must be shifted to match each other when merging; this option instead prefixes the specified path (or strips it from the beginning) to make the shape of the two trees match. ๐ฆ
๐ recursive
This is now a synonym for ort. It was an alternative implementation until v2.49.0, but got redirected to mean ort in v2.50.0. And for the history girlies: the previous recursive strategy was the default strategy for resolving two heads from Git v0.99.9k until v2.33.0. ๐
๐ resolve
This can only resolve two heads (i.e. the current branch and another branch you pulled from) using a 3-way merge algorithm. It tries to carefully detect criss-cross merge ambiguities. It does not handle renames. ๐
๐ธ octopus
This resolves cases with more than two heads, but it refuses to do a complex merge that needs manual resolution. It's primarily meant to be used for bundling topic branch heads together. This is the default merge strategy when pulling or merging more than one branch. Eight arms, zero patience for conflicts. ๐
โญ ours
This resolves any number of heads, but the resulting tree of the merge is always that of the current branch head โ effectively ignoring all changes from all other branches. It's meant to be used to supersede old development history of side branches. Note that this is different from the -Xours option to the ort merge strategy. Same name, whole different creature. ๐
๐ subtree
This is a modified ort strategy. When merging trees A and B, if B corresponds to a subtree of A, B is first adjusted to match the tree structure of A, instead of reading the trees at the same level. This adjustment is also done to the common ancestor tree. ๐ณ
With the strategies that use 3-way merge (including the default, ort), if a change is made on both branches but later reverted on one of the branches, that change will be present in the merged result. Some people find this behavior confusing โ and honestly, fair ๐ญ โ but it happens because only the heads and the merge base are considered when performing a merge, not the individual commits. So the merge algorithm looks at the reverted change and sees no change at all, and substitutes the changed version instead. Not a bug, just how the math shakes out. ๐งฎ
โ๏ธ CONFIGURATION โ๏ธ
okay bestie, this is the config corner โ the little knobs that change how git merge behaves before you even touch the command line โจ
branch.<name>.mergeOptionsโ sets the default options for merging into branch <name>. The syntax and supported options are exactly the same as those ofgit merge, but heads up: option values containing whitespace characters are currently not supported ๐ญ
๐จ Quick note, bestie: everything above this line in this section isnโt included from the git-config(1) documentation. The content that follows is the same as whatโs found there:
merge.conflictStyleโ tells Git what style to use when it writes conflicted hunks out to working tree files after a merge. The default is"merge", which shows a<<<<<<<conflict marker, changes made by one side, a=======marker, changes made by the other side, and then a>>>>>>>marker. An alternate style,"diff3", adds a|||||||marker and the original text before the=======marker. The"merge"style tends to produce smaller conflict regions thandiff3, both because of the exclusion of the original text, and because when a subset of lines match on the two sides, they are just pulled out of the conflict region. Another alternate style,"zdiff3", is similar todiff3but removes matching lines on the two sides from the conflict region when those matching lines appear near either the beginning or end of a conflict region. Conflict drama, but make it configurable ๐merge.defaultToUpstreamโ if merge is called without any commit argument, merge the upstream branches configured for the current branch by using their last observed values stored in their remote-tracking branches. The values of thebranch.<current branch>.mergethat name the branches at the remote named bybranch.<current-branch>.remoteare consulted, and then they are mapped viaremote.<remote>.fetchto their corresponding remote-tracking branches, and the tips of these tracking branches are merged. Defaults totrue.merge.ffโ by default, Git does not create an extra merge commit when merging a commit that is a descendant of the current commit. Instead, the tip of the current branch is fast-forwarded. When set tofalse, this variable tells Git to create an extra merge commit in such a case (equivalent to giving the--no-ffoption from the command line). When set toonly, only such fast-forward merges are allowed (equivalent to giving the--ff-onlyoption from the command line).merge.verifySignaturesโ iftrue, this is equivalent to the--verify-signaturescommand line option. Seegit-merge(1)for details.merge.branchdescโ in addition to branch names, populate the log message with the branch description text associated with them. Defaults tofalse.merge.logโ in addition to branch names, populate the log message with at most the specified number of one-line descriptions from the actual commits that are being merged. Defaults tofalse, andtrueis a synonym for20.merge.suppressDestโ by adding a glob that matches the names of integration branches to this multi-valued configuration variable, the default merge message computed for merges into these integration branches will omit"into <branch-name>"from its title. An element with an empty value can be used to clear the list of globs accumulated from previous configuration entries. When there is nomerge.suppressDestvariable defined, the default value ofmasteris used for backward compatibility.merge.renameLimitโ the number of files to consider in the exhaustive portion of rename detection during a merge. If not specified, defaults to the value ofdiff.renameLimit. If neithermerge.renameLimitnordiff.renameLimitare specified, currently defaults to7000. This setting has no effect if rename detection is turned off.merge.renamesโ whether Git detects renames. If set tofalse, rename detection is disabled. If set totrue, basic rename detection is enabled. Defaults to the value ofdiff.renames.merge.directoryRenamesโ whether Git detects directory renames, affecting what happens at merge time to new files added to a directory on one side of history when that directory was renamed on the other side of history. Possible values are:falseโ directory rename detection is disabled, meaning that such new files will be left behind in the old directory.trueโ directory rename detection is enabled, meaning that such new files will be moved into the new directory.conflictโ a conflict will be reported for such paths.
If merge.renames is false, merge.directoryRenames is ignored and treated as false. Defaults to conflict.
merge.renormalizeโ tell Git that canonical representation of files in the repository has changed over time (e.g. earlier commits record text files with CRLF line endings, but recent ones use LF line endings). In such a repository, for each file where a three-way content merge is needed, Git can convert the data recorded in commits to a canonical form before performing a merge to reduce unnecessary conflicts. For more information, see section"Merging branches with differing checkin/checkout attributes"ingitattributes(5).merge.statโ what, if anything, to print betweenORIG_HEADand the merge result at the end of the merge. Possible values are:falseโ show nothing.trueโ showgit diff --diffstat --summary ORIG_HEAD.compactโ showgit diff --compact-summary ORIG_HEAD.
but any unrecognised value (e.g., a value added by a future version of Git) is taken as true instead of triggering an error. Defaults to true.
merge.autoStashโ when set totrue, automatically create a temporary stash entry before the operation begins, and apply it after the operation ends. This means that you can run merge on a dirty worktree. However, use with care: the final stash application after a successful merge might result in non-trivial conflicts. This option can be overridden by the--no-autostashand--autostashoptions ofgit-merge(1). Defaults tofalse.merge.toolโ controls which merge tool is used bygit-mergetool(1). The built-in values are the same shared list below. Any other value is treated as a custom merge tool and requires that a correspondingmergetool.<tool>.cmdvariable is defined.merge.guitoolโ controls which merge tool is used bygit-mergetool(1)when the-g/--guiflag is specified. The built-in values are the same shared list below. Any other value is treated as a custom merge tool and requires that a correspondingmergetool.<guitool>.cmdvariable is defined.
๐ Built-in merge tools for merge.tool and merge.guitool ๐
araxisโ use Araxis Merge (requires a graphical session)bcโ use Beyond Compare (requires a graphical session)bc3โ use Beyond Compare (requires a graphical session)bc4โ use Beyond Compare (requires a graphical session)codecompareโ use Code Compare (requires a graphical session)deltawalkerโ use DeltaWalker (requires a graphical session)diffmergeโ use DiffMerge (requires a graphical session)diffuseโ use Diffuse (requires a graphical session)ecmergeโ use ECMerge (requires a graphical session)emergeโ use Emacs' Emergeexamdiffโ use ExamDiff Pro (requires a graphical session)guiffyโ use Guiffyโs Diff Tool (requires a graphical session)gvimdiffโ use gVim (requires a graphical session) with a custom layout (seegit help mergetool's BACKEND SPECIFIC HINTS section)gvimdiff1โ use gVim (requires a graphical session) with a 2 panes layout (LOCAL and REMOTE)gvimdiff2โ use gVim (requires a graphical session) with a 3 panes layout (LOCAL, MERGED and REMOTE)gvimdiff3โ use gVim (requires a graphical session) where only the MERGED file is shownkdiff3โ use KDiff3 (requires a graphical session)meldโ use Meld (requires a graphical session) with optional auto merge (seegit help mergetool's CONFIGURATION section)nvimdiffโ use Neovim with a custom layout (seegit help mergetool's BACKEND SPECIFIC HINTS section)nvimdiff1โ use Neovim with a 2 panes layout (LOCAL and REMOTE)nvimdiff2โ use Neovim with a 3 panes layout (LOCAL, MERGED and REMOTE)nvimdiff3โ use Neovim where only the MERGED file is shownopendiffโ use FileMerge (requires a graphical session)p4mergeโ use HelixCore P4Merge (requires a graphical session)smergeโ use Sublime Merge (requires a graphical session)tkdiffโ use TkDiff (requires a graphical session)tortoisemergeโ use TortoiseMerge (requires a graphical session)vimdiffโ use Vim with a custom layout (seegit help mergetool's BACKEND SPECIFIC HINTS section)vimdiff1โ use Vim with a 2 panes layout (LOCAL and REMOTE)vimdiff2โ use Vim with a 3 panes layout (LOCAL, MERGED and REMOTE)vimdiff3โ use Vim where only the MERGED file is shownvscodeโ use Visual Studio Code (requires a graphical session)winmergeโ use WinMerge (requires a graphical session)xxdiffโ use xxdiff (requires a graphical session)merge.verbosityโ controls the amount of output shown by the recursive merge strategy. Level0outputs nothing except a final error message if conflicts were detected. Level1outputs only conflicts,2outputs conflicts and file changes. Level5and above outputs debugging information. The default is level2. Can be overridden by theGIT_MERGE_VERBOSITYenvironment variable.merge.<driver>.nameโ defines a human-readable name for a custom low-level merge driver. Seegitattributes(5)for details.merge.<driver>.driverโ defines the command that implements a custom low-level merge driver. Seegitattributes(5)for details.merge.<driver>.recursiveโ names a low-level merge driver to be used when performing an internal merge between common ancestors. Seegitattributes(5)for details.
๐ SEE ALSO ๐
git-fmt-merge-msg(1)git-pull(1)gitattributes(5)git-reset(1)git-diff(1)git-ls-files(1)git-add(1)git-rm(1)git-mergetool(1)
๐ GIT
Part of the git(1) suite
and that's the whole page, bestie!! ๐ you've officially read all of GIT-MERGE(1) and honestly? obsessed with your dedication ๐
okay so real talk โ this lil doc is Git 2.56.0, dated 2026-09-27, and it's page GIT-MERGE(1) of the suite. no cap, that's the source, the version, and the date all in one ๐ซถ
now go forth and merge, and may your conflicts be few and your fast-forwards be iconic โจ๐ฆ๐
๐ฆ where this page comes from
- arch rolling: git 2.56.0-1 ยท GPL-2.0-only
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms