{
    "mode": "man",
    "parameter": "GIT-MERGE",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/GIT-MERGE/1/json",
    "generated": "2026-06-16T10:03:26Z",
    "synopsis": "git merge [-n] [--stat] [--no-commit] [--squash] [--[no-]edit]\n[--no-verify] [-s <strategy>] [-X <strategy-option>] [-S[<keyid>]]\n[--[no-]allow-unrelated-histories]\n[--[no-]rerere-autoupdate] [-m <msg>] [-F <file>] [<commit>...]\ngit merge (--continue | --abort | --quit)",
    "sections": {
        "NAME": {
            "content": "git-merge - Join two or more development histories together\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "git merge [-n] [--stat] [--no-commit] [--squash] [--[no-]edit]\n[--no-verify] [-s <strategy>] [-X <strategy-option>] [-S[<keyid>]]\n[--[no-]allow-unrelated-histories]\n[--[no-]rerere-autoupdate] [-m <msg>] [-F <file>] [<commit>...]\ngit merge (--continue | --abort | --quit)\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Incorporates changes from the named commits (since the time their histories diverged from the\ncurrent branch) into the current branch. This command is used by git pull to incorporate\nchanges from another repository and can be used by hand to merge changes from one branch into\nanother.\n\nAssume the following history exists and the current branch is \"master\":\n\nA---B---C topic\n/\nD---E---F---G master\n\nThen \"git merge topic\" will replay the changes made on the topic branch since it diverged\nfrom master (i.e., E) until its current commit (C) on top of master, and record the result in\na new commit along with the names of the two parent commits and a log message from the user\ndescribing the changes.\n\nA---B---C topic\n/         \\\nD---E---F---G---H master\n\nThe second syntax (\"git merge --abort\") can only be run after the merge has resulted in\nconflicts. git merge --abort will abort the merge process and try to reconstruct the\npre-merge state. However, if there were uncommitted changes when the merge started (and\nespecially if those changes were further modified after the merge was started), git merge\n--abort will in some cases be unable to reconstruct the original (pre-merge) changes.\nTherefore:\n\nWarning: Running git merge with non-trivial uncommitted changes is discouraged: while\npossible, it may leave you in a state that is hard to back out of in the case of a conflict.\n\nThe third syntax (\"git merge --continue\") can only be run after the merge has resulted in\nconflicts.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "--commit, --no-commit",
                    "content": "Perform the merge and commit the result. This option can be used to override --no-commit.\n\nWith --no-commit perform the merge and stop just before creating a merge commit, to give\nthe user a chance to inspect and further tweak the merge result before committing.\n\nNote that fast-forward updates do not create a merge commit and therefore there is no way\nto stop those merges with --no-commit. Thus, if you want to ensure your branch is not\nchanged or updated by the merge command, use --no-ff with --no-commit.\n",
                    "long": "--no-commit"
                },
                {
                    "name": "--edit, -e, --no-edit",
                    "content": "Invoke an editor before committing successful mechanical merge to further edit the\nauto-generated merge message, so that the user can explain and justify the merge. The\n--no-edit option can be used to accept the auto-generated message (this is generally\ndiscouraged). The --edit (or -e) option is still useful if you are giving a draft message\nwith the -m option from the command line and want to edit it in the editor.\n\nOlder scripts may depend on the historical behaviour of not allowing the user to edit the\nmerge log message. They will see an editor opened when they run git merge. To make it\neasier to adjust such scripts to the updated behaviour, the environment variable\nGITMERGEAUTOEDIT can be set to no at the beginning of them.\n\n--cleanup=<mode>\nThis option determines how the merge message will be cleaned up before committing. See\ngit-commit(1) for more details. In addition, if the <mode> is given a value of scissors,\nscissors will be appended to MERGEMSG before being passed on to the commit machinery in\nthe case of a merge conflict.\n",
                    "flag": "-e",
                    "long": "--no-edit"
                },
                {
                    "name": "--ff, --no-ff, --ff-only",
                    "content": "Specifies how a merge is handled when the merged-in history is already a descendant of\nthe current history.  --ff is the default unless merging an annotated (and possibly\nsigned) tag that is not stored in its natural place in the refs/tags/ hierarchy, in which\ncase --no-ff is assumed.\n\nWith --ff, when possible resolve the merge as a fast-forward (only update the branch\npointer to match the merged branch; do not create a merge commit). When not possible\n(when the merged-in history is not a descendant of the current history), create a merge\ncommit.\n\nWith --no-ff, create a merge commit in all cases, even when the merge could instead be\nresolved as a fast-forward.\n\nWith --ff-only, resolve the merge as a fast-forward when possible. When not possible,\nrefuse to merge and exit with a non-zero status.\n\n-S[<keyid>], --gpg-sign[=<keyid>], --no-gpg-sign\nGPG-sign the resulting merge commit. The keyid argument is optional and defaults to the\ncommitter identity; if specified, it must be stuck to the option without a space.\n--no-gpg-sign is useful to countermand both commit.gpgSign configuration variable, and\nearlier --gpg-sign.\n\n--log[=<n>], --no-log\nIn addition to branch names, populate the log message with one-line descriptions from at\nmost <n> actual commits that are being merged. See also git-fmt-merge-msg(1).\n\nWith --no-log do not list one-line descriptions from the actual commits being merged.\n",
                    "long": "--ff-only"
                },
                {
                    "name": "--signoff, --no-signoff",
                    "content": "Add a Signed-off-by trailer by the committer at the end of the commit log message. The\nmeaning of a signoff depends on the project to which you're committing. For example, it\nmay certify that the committer has the rights to submit the work under the project's\nlicense or agrees to some contributor representation, such as a Developer Certificate of\nOrigin. (See http://developercertificate.org for the one used by the Linux kernel and Git\nprojects.) Consult the documentation or leadership of the project to which you're\ncontributing to understand how the signoffs are used in that project.\n\nThe --no-signoff option can be used to countermand an earlier --signoff option on the\ncommand line.\n",
                    "long": "--no-signoff"
                },
                {
                    "name": "--stat, -n, --no-stat",
                    "content": "Show a diffstat at the end of the merge. The diffstat is also controlled by the\nconfiguration option merge.stat.\n\nWith -n or --no-stat do not show a diffstat at the end of the merge.\n",
                    "flag": "-n",
                    "long": "--no-stat"
                },
                {
                    "name": "--squash, --no-squash",
                    "content": "Produce the working tree and index state as if a real merge happened (except for the\nmerge information), but do not actually make a commit, move the HEAD, or record\n$GITDIR/MERGEHEAD (to cause the next git commit command to create a merge commit). This\nallows you to create a single commit on top of the current branch whose effect is the\nsame as merging another branch (or more in case of an octopus).\n\nWith --no-squash perform the merge and commit the result. This option can be used to\noverride --squash.\n\nWith --squash, --commit is not allowed, and will fail.\n\n--[no-]verify\nBy default, the pre-merge and commit-msg hooks are run. When --no-verify is given, these\nare bypassed. See also githooks(5).\n\n-s <strategy>, --strategy=<strategy>\nUse the given merge strategy; can be supplied more than once to specify them in the order\nthey should be tried. If there is no -s option, a built-in list of strategies is used\ninstead (ort when merging a single head, octopus otherwise).\n\n-X <option>, --strategy-option=<option>\nPass merge strategy specific option through to the merge strategy.\n",
                    "long": "--no-squash"
                },
                {
                    "name": "--verify-signatures, --no-verify-signatures",
                    "content": "Verify that the tip commit of the side branch being merged is signed with a valid key,\ni.e. a key that has a valid uid: in the default trust model, this means the signing key\nhas been signed by a trusted key. If the tip commit of the side branch is not signed with\na valid key, the merge is aborted.\n",
                    "long": "--no-verify-signatures"
                },
                {
                    "name": "--summary, --no-summary",
                    "content": "Synonyms to --stat and --no-stat; these are deprecated and will be removed in the future.\n",
                    "long": "--no-summary"
                },
                {
                    "name": "-q, --quiet",
                    "content": "Operate quietly. Implies --no-progress.\n",
                    "flag": "-q",
                    "long": "--quiet"
                },
                {
                    "name": "-v, --verbose",
                    "content": "Be verbose.\n",
                    "flag": "-v",
                    "long": "--verbose"
                },
                {
                    "name": "--progress, --no-progress",
                    "content": "Turn progress on/off explicitly. If neither is specified, progress is shown if standard\nerror is connected to a terminal. Note that not all merge strategies may support progress\nreporting.\n",
                    "long": "--no-progress"
                },
                {
                    "name": "--autostash, --no-autostash",
                    "content": "Automatically create a temporary stash entry before the operation begins, record it in\nthe special ref MERGEAUTOSTASH and apply it after the operation ends. This means that\nyou can run the operation on a dirty worktree. However, use with care: the final stash\napplication after a successful merge might result in non-trivial conflicts.\n",
                    "long": "--no-autostash"
                },
                {
                    "name": "--allow-unrelated-histories",
                    "content": "By default, git merge command refuses to merge histories that do not share a common\nancestor. This option can be used to override this safety when merging histories of two\nprojects that started their lives independently. As that is a very rare occasion, no\nconfiguration variable to enable this by default exists and will not be added.\n",
                    "long": "--allow-unrelated-histories"
                },
                {
                    "name": "-m <msg>",
                    "content": "Set the commit message to be used for the merge commit (in case one is created).\n\nIf --log is specified, a shortlog of the commits being merged will be appended to the\nspecified message.\n\nThe git fmt-merge-msg command can be used to give a good default for automated git merge\ninvocations. The automated message can include the branch description.\n\n-F <file>, --file=<file>\nRead the commit message to be used for the merge commit (in case one is created).\n\nIf --log is specified, a shortlog of the commits being merged will be appended to the\nspecified message.\n",
                    "flag": "-m",
                    "arg": "<msg>"
                },
                {
                    "name": "--rerere-autoupdate, --no-rerere-autoupdate",
                    "content": "Allow the rerere mechanism to update the index with the result of auto-conflict\nresolution if possible.\n",
                    "long": "--no-rerere-autoupdate"
                },
                {
                    "name": "--overwrite-ignore, --no-overwrite-ignore",
                    "content": "Silently overwrite ignored files from the merge result. This is the default behavior. Use\n--no-overwrite-ignore to abort.\n",
                    "long": "--no-overwrite-ignore"
                },
                {
                    "name": "--abort",
                    "content": "Abort the current conflict resolution process, and try to reconstruct the pre-merge\nstate. If an autostash entry is present, apply it to the worktree.\n\nIf there were uncommitted worktree changes present when the merge started, git merge\n--abort will in some cases be unable to reconstruct these changes. It is therefore\nrecommended to always commit or stash your changes before running git merge.\n\ngit merge --abort is equivalent to git reset --merge when MERGEHEAD is present unless\nMERGEAUTOSTASH is also present in which case git merge --abort applies the stash entry\nto the worktree whereas git reset --merge will save the stashed changes in the stash\nlist.\n",
                    "long": "--abort"
                },
                {
                    "name": "--quit",
                    "content": "Forget about the current merge in progress. Leave the index and the working tree as-is.\nIf MERGEAUTOSTASH is present, the stash entry will be saved to the stash list.\n",
                    "long": "--quit"
                },
                {
                    "name": "--continue",
                    "content": "After a git merge stops due to conflicts you can conclude the merge by running git merge\n--continue (see \"HOW TO RESOLVE CONFLICTS\" section below).\n\n<commit>...\nCommits, usually other branch heads, to merge into our branch. Specifying more than one\ncommit will create a merge with more than two parents (affectionately called an Octopus\nmerge).\n\nIf no commit is given from the command line, merge the remote-tracking branches that the\ncurrent branch is configured to use as its upstream. See also the configuration section\nof this manual page.\n\nWhen FETCHHEAD (and no other commit) is specified, the branches recorded in the\n.git/FETCHHEAD file by the previous invocation of git fetch for merging are merged to\nthe current branch.\n",
                    "long": "--continue"
                }
            ]
        },
        "PRE-MERGE CHECKS": {
            "content": "Before applying outside changes, you should get your own work in good shape and committed\nlocally, so it will not be clobbered if there are conflicts. See also git-stash(1). git pull\nand git merge will stop without doing anything when local uncommitted changes overlap with\nfiles that git pull/git merge may need to update.\n\nTo avoid recording unrelated changes in the merge commit, git pull and git merge will also\nabort if there are any changes registered in the index relative to the HEAD commit. (Special\nnarrow exceptions to this rule may exist depending on which merge strategy is in use, but\ngenerally, the index must match HEAD.)\n\nIf all named commits are already ancestors of HEAD, git merge will exit early with the\nmessage \"Already up to date.\"\n",
            "subsections": []
        },
        "FAST-FORWARD MERGE": {
            "content": "Often the current branch head is an ancestor of the named commit. This is the most common\ncase especially when invoked from git pull: you are tracking an upstream repository, you have\ncommitted no local changes, and now you want to update to a newer upstream revision. In this\ncase, a new commit is not needed to store the combined history; instead, the HEAD (along with\nthe index) is updated to point at the named commit, without creating an extra merge commit.\n\nThis behavior can be suppressed with the --no-ff option.\n",
            "subsections": []
        },
        "TRUE MERGE": {
            "content": "Except in a fast-forward merge (see above), the branches to be merged must be tied together\nby a merge commit that has both of them as its parents.\n\nA merged version reconciling the changes from all branches to be merged is committed, and\nyour HEAD, index, and working tree are updated to it. It is possible to have modifications in\nthe working tree as long as they do not overlap; the update will preserve them.\n\nWhen it is not obvious how to reconcile the changes, the following happens:\n\n1. The HEAD pointer stays the same.\n\n2. The MERGEHEAD ref is set to point to the other branch head.\n\n3. Paths that merged cleanly are updated both in the index file and in your working tree.\n\n4. For conflicting paths, the index file records up to three versions: stage 1 stores the\nversion from the common ancestor, stage 2 from HEAD, and stage 3 from MERGEHEAD (you can\ninspect the stages with git ls-files -u). The working tree files contain the result of\nthe \"merge\" program; i.e. 3-way merge results with familiar conflict markers <<< === >>>.\n\n5. No other changes are made. In particular, the local modifications you had before you\nstarted merge will stay the same and the index entries for them stay as they were, i.e.\nmatching HEAD.\n\nIf you tried a merge which resulted in complex conflicts and want to start over, you can\nrecover with git merge --abort.\n",
            "subsections": []
        },
        "MERGING TAG": {
            "content": "When merging an annotated (and possibly signed) tag, Git always creates a merge commit even\nif a fast-forward merge is possible, and the commit message template is prepared with the tag\nmessage. Additionally, if the tag is signed, the signature check is reported as a comment in\nthe message template. See also git-tag(1).\n\nWhen you want to just integrate with the work leading to the commit that happens to be\ntagged, e.g. synchronizing with an upstream release point, you may not want to make an\nunnecessary merge commit.\n\nIn such a case, you can \"unwrap\" the tag yourself before feeding it to git merge, or pass\n--ff-only when you do not have any work on your own. e.g.\n\ngit fetch origin\ngit merge v1.2.3^0\ngit merge --ff-only v1.2.3\n",
            "subsections": []
        },
        "HOW CONFLICTS ARE PRESENTED": {
            "content": "During a merge, the working tree files are updated to reflect the result of the merge. Among\nthe changes made to the common ancestor's version, non-overlapping ones (that is, you changed\nan area of the file while the other side left that area intact, or vice versa) are\nincorporated in the final result verbatim. When both sides made changes to the same area,\nhowever, Git cannot randomly pick one side over the other, and asks you to resolve it by\nleaving what both sides did to that area.\n\nBy default, Git uses the same style as the one used by the \"merge\" program from the RCS suite\nto present such a conflicted hunk, like this:\n\nHere are lines that are either unchanged from the common\nancestor, or cleanly resolved because only one side changed.\n<<<<<<< yours:sample.txt\nConflict resolution is hard;\nlet's go shopping.\n=======\nGit makes conflict resolution easy.\n>>>>>>> theirs:sample.txt\nAnd here is another line that is cleanly resolved or unmodified.\n\nThe area where a pair of conflicting changes happened is marked with markers <<<<<<<,\n=======, and >>>>>>>. The part before the ======= is typically your side, and the part\nafterwards is typically their side.\n\nThe default format does not show what the original said in the conflicting area. You cannot\ntell how many lines are deleted and replaced with Barbie's remark on your side. The only\nthing you can tell is that your side wants to say it is hard and you'd prefer to go shopping,\nwhile the other side wants to claim it is easy.\n\nAn alternative style can be used by setting the \"merge.conflictStyle\" configuration variable\nto \"diff3\". In \"diff3\" style, the above conflict may look like this:\n\nHere are lines that are either unchanged from the common\nancestor, or cleanly resolved because only one side changed.\n<<<<<<< yours:sample.txt\nConflict resolution is hard;\nlet's go shopping.\n|||||||\nConflict resolution is hard.\n=======\nGit makes conflict resolution easy.\n>>>>>>> theirs:sample.txt\nAnd here is another line that is cleanly resolved or unmodified.\n\nIn addition to the <<<<<<<, =======, and >>>>>>> markers, it uses another ||||||| marker that\nis followed by the original text. You can tell that the original just stated a fact, and your\nside simply gave in to that statement and gave up, while the other side tried to have a more\npositive attitude. You can sometimes come up with a better resolution by viewing the\noriginal.\n",
            "subsections": []
        },
        "HOW TO RESOLVE CONFLICTS": {
            "content": "After seeing a conflict, you can do two things:\n\no   Decide not to merge. The only clean-ups you need are to reset the index file to the HEAD\ncommit to reverse 2. and to clean up working tree changes made by 2. and 3.; git merge\n--abort can be used for this.\n\no   Resolve the conflicts. Git will mark the conflicts in the working tree. Edit the files\ninto shape and git add them to the index. Use git commit or git merge --continue to seal\nthe deal. The latter command checks whether there is a (interrupted) merge in progress\nbefore calling git commit.\n\nYou can work through the conflict with a number of tools:\n\no   Use a mergetool.  git mergetool to launch a graphical mergetool which will work you\nthrough the merge.\n\no   Look at the diffs.  git diff will show a three-way diff, highlighting changes from both\nthe HEAD and MERGEHEAD versions.\n\no   Look at the diffs from each branch.  git log --merge -p <path> will show diffs first for\nthe HEAD version and then the MERGEHEAD version.\n\no   Look at the originals.  git show :1:filename shows the common ancestor, git show\n:2:filename shows the HEAD version, and git show :3:filename shows the MERGEHEAD\nversion.\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "o   Merge branches fixes and enhancements on top of the current branch, making an octopus\nmerge:\n\n$ git merge fixes enhancements\n\no   Merge branch obsolete into the current branch, using ours merge strategy:\n\n$ git merge -s ours obsolete\n\no   Merge branch maint into the current branch, but do not make a new commit automatically:\n\n$ git merge --no-commit maint\n\nThis can be used when you want to include further changes to the merge, or want to write\nyour own merge commit message.\n\nYou should refrain from abusing this option to sneak substantial changes into a merge\ncommit. Small fixups like bumping release/version name would be acceptable.\n",
            "subsections": []
        },
        "MERGE STRATEGIES": {
            "content": "The merge mechanism (git merge and git pull commands) allows the backend merge strategies to\nbe chosen with -s option. Some strategies can also take their own options, which can be\npassed by giving -X<option> arguments to git merge and/or git pull.\n\nort\nThis is the default merge strategy when pulling or merging one branch. This strategy can\nonly resolve two heads using a 3-way merge algorithm. When there is more than one common\nancestor that can be used for 3-way merge, it creates a merged tree of the common\nancestors and uses that as the reference tree for the 3-way merge. This has been reported\nto result in fewer merge conflicts without causing mismerges by tests done on actual\nmerge commits taken from Linux 2.6 kernel development history. Additionally this strategy\ncan detect and handle merges involving renames. It does not make use of detected copies.\nThe name for this algorithm is an acronym (\"Ostensibly Recursive's Twin\") and came from\nthe fact that it was written as a replacement for the previous default algorithm,\nrecursive.\n\nThe ort strategy can take the following options:\n\nours\nThis option forces conflicting hunks to be auto-resolved cleanly by favoring our\nversion. Changes from the other tree that do not conflict with our side are reflected\nin the merge result. For a binary file, the entire contents are taken from our side.\n\nThis should not be confused with the ours merge strategy, which does not even look at\nwhat the other tree contains at all. It discards everything the other tree did,\ndeclaring our history contains all that happened in it.\n\ntheirs\nThis is the opposite of ours; note that, unlike ours, there is no theirs merge\nstrategy to confuse this merge option with.\n\nignore-space-change, ignore-all-space, ignore-space-at-eol, ignore-cr-at-eol\nTreats lines with the indicated type of whitespace change as unchanged for the sake\nof a three-way merge. Whitespace changes mixed with other changes to a line are not\nignored. See also git-diff(1) -b, -w, --ignore-space-at-eol, and --ignore-cr-at-eol.\n\no   If their version only introduces whitespace changes to a line, our version is\nused;\n\no   If our version introduces whitespace changes but their version includes a\nsubstantial change, their version is used;\n\no   Otherwise, the merge proceeds in the usual way.\n\nrenormalize\nThis runs a virtual check-out and check-in of all three stages of a file when\nresolving a three-way merge. This option is meant to be used when merging branches\nwith different clean filters or end-of-line normalization rules. See \"Merging\nbranches with differing checkin/checkout attributes\" in gitattributes(5) for details.\n\nno-renormalize\nDisables the renormalize option. This overrides the merge.renormalize configuration\nvariable.\n\nfind-renames[=<n>]\nTurn on rename detection, optionally setting the similarity threshold. This is the\ndefault. This overrides the merge.renames configuration variable. See also git-\ndiff(1) --find-renames.\n\nrename-threshold=<n>\nDeprecated synonym for find-renames=<n>.\n\nsubtree[=<path>]\nThis option is a more advanced form of subtree strategy, where the strategy makes a\nguess on how two trees must be shifted to match with each other when merging.\nInstead, the specified path is prefixed (or stripped from the beginning) to make the\nshape of two trees to match.\n\nrecursive\nThis can only resolve two heads using a 3-way merge algorithm. When there is more than\none common ancestor that can be used for 3-way merge, it creates a merged tree of the\ncommon ancestors and uses that as the reference tree for the 3-way merge. This has been\nreported to result in fewer merge conflicts without causing mismerges by tests done on\nactual merge commits taken from Linux 2.6 kernel development history. Additionally this\ncan detect and handle merges involving renames. It does not make use of detected copies.\nThis was the default strategy for resolving two heads from Git v0.99.9k until v2.33.0.\n\nThe recursive strategy takes the same options as ort. However, there are three additional\noptions that ort ignores (not documented above) that are potentially useful with the\nrecursive strategy:\n\npatience\nDeprecated synonym for diff-algorithm=patience.\n\ndiff-algorithm=[patience|minimal|histogram|myers]\nUse a different diff algorithm while merging, which can help avoid mismerges that\noccur due to unimportant matching lines (such as braces from distinct functions). See\nalso git-diff(1) --diff-algorithm. Note that ort specifically uses\ndiff-algorithm=histogram, while recursive defaults to the diff.algorithm config\nsetting.\n\nno-renames\nTurn off rename detection. This overrides the merge.renames configuration variable.\nSee also git-diff(1) --no-renames.\n\nresolve\nThis can only resolve two heads (i.e. the current branch and another branch you pulled\nfrom) using a 3-way merge algorithm. It tries to carefully detect criss-cross merge\nambiguities. It does not handle renames.\n\noctopus\nThis resolves cases with more than two heads, but refuses to do a complex merge that\nneeds manual resolution. It is primarily meant to be used for bundling topic branch heads\ntogether. This is the default merge strategy when pulling or merging more than one\nbranch.\n\nours\nThis resolves any number of heads, but the resulting tree of the merge is always that of\nthe current branch head, effectively ignoring all changes from all other branches. It is\nmeant to be used to supersede old development history of side branches. Note that this is\ndifferent from the -Xours option to the recursive merge strategy.\n\nsubtree\nThis is a modified ort strategy. When merging trees A and B, if B corresponds to a\nsubtree of A, B is first adjusted to match the tree structure of A, instead of reading\nthe trees at the same level. This adjustment is also done to the common ancestor tree.\n\nWith the strategies that use 3-way merge (including the default, ort), if a change is made on\nboth branches, but later reverted on one of the branches, that change will be present in the\nmerged result; some people find this behavior confusing. It occurs because only the heads and\nthe merge base are considered when performing a merge, not the individual commits. The merge\nalgorithm therefore considers the reverted change as no change at all, and substitutes the\nchanged version instead.\n",
            "subsections": []
        },
        "CONFIGURATION": {
            "content": "merge.conflictStyle\nSpecify the style in which conflicted hunks are written out to working tree files upon\nmerge. The default is \"merge\", which shows a <<<<<<< conflict marker, changes made by one\nside, a ======= marker, changes made by the other side, and then a >>>>>>> marker. An\nalternate style, \"diff3\", adds a ||||||| marker and the original text before the =======\nmarker.\n\nmerge.defaultToUpstream\nIf merge is called without any commit argument, merge the upstream branches configured\nfor the current branch by using their last observed values stored in their\nremote-tracking branches. The values of the branch.<current branch>.merge that name the\nbranches at the remote named by branch.<current branch>.remote are consulted, and then\nthey are mapped via remote.<remote>.fetch to their corresponding remote-tracking\nbranches, and the tips of these tracking branches are merged. Defaults to true.\n\nmerge.ff\nBy default, Git does not create an extra merge commit when merging a commit that is a\ndescendant of the current commit. Instead, the tip of the current branch is\nfast-forwarded. When set to false, this variable tells Git to create an extra merge\ncommit in such a case (equivalent to giving the --no-ff option from the command line).\nWhen set to only, only such fast-forward merges are allowed (equivalent to giving the\n--ff-only option from the command line).\n\nmerge.verifySignatures\nIf true, this is equivalent to the --verify-signatures command line option. See git-\nmerge(1) for details.\n\nmerge.branchdesc\nIn addition to branch names, populate the log message with the branch description text\nassociated with them. Defaults to false.\n\nmerge.log\nIn addition to branch names, populate the log message with at most the specified number\nof one-line descriptions from the actual commits that are being merged. Defaults to\nfalse, and true is a synonym for 20.\n\nmerge.suppressDest\nBy adding a glob that matches the names of integration branches to this multi-valued\nconfiguration variable, the default merge message computed for merges into these\nintegration branches will omit \"into <branch name>\" from its title.\n\nAn element with an empty value can be used to clear the list of globs accumulated from\nprevious configuration entries. When there is no merge.suppressDest variable defined, the\ndefault value of master is used for backward compatibility.\n\nmerge.renameLimit\nThe number of files to consider in the exhaustive portion of rename detection during a\nmerge. If not specified, defaults to the value of diff.renameLimit. If neither\nmerge.renameLimit nor diff.renameLimit are specified, currently defaults to 7000. This\nsetting has no effect if rename detection is turned off.\n\nmerge.renames\nWhether Git detects renames. If set to \"false\", rename detection is disabled. If set to\n\"true\", basic rename detection is enabled. Defaults to the value of diff.renames.\n\nmerge.directoryRenames\nWhether Git detects directory renames, affecting what happens at merge time to new files\nadded to a directory on one side of history when that directory was renamed on the other\nside of history. If merge.directoryRenames is set to \"false\", directory rename detection\nis disabled, meaning that such new files will be left behind in the old directory. If set\nto \"true\", directory rename detection is enabled, meaning that such new files will be\nmoved into the new directory. If set to \"conflict\", a conflict will be reported for such\npaths. If merge.renames is false, merge.directoryRenames is ignored and treated as false.\nDefaults to \"conflict\".\n\nmerge.renormalize\nTell Git that canonical representation of files in the repository has changed over time\n(e.g. earlier commits record text files with CRLF line endings, but recent ones use LF\nline endings). In such a repository, Git can convert the data recorded in commits to a\ncanonical form before performing a merge to reduce unnecessary conflicts. For more\ninformation, see section \"Merging branches with differing checkin/checkout attributes\" in\ngitattributes(5).\n\nmerge.stat\nWhether to print the diffstat between ORIGHEAD and the merge result at the end of the\nmerge. True by default.\n\nmerge.autoStash\nWhen set to true, automatically create a temporary stash entry before the operation\nbegins, and apply it after the operation ends. This means that you can run merge on a\ndirty worktree. However, use with care: the final stash application after a successful\nmerge might result in non-trivial conflicts. This option can be overridden by the\n--no-autostash and --autostash options of git-merge(1). Defaults to false.\n\nmerge.tool\nControls which merge tool is used by git-mergetool(1). The list below shows the valid\nbuilt-in values. Any other value is treated as a custom merge tool and requires that a\ncorresponding mergetool.<tool>.cmd variable is defined.\n\nmerge.guitool\nControls which merge tool is used by git-mergetool(1) when the -g/--gui flag is\nspecified. The list below shows the valid built-in values. Any other value is treated as\na custom merge tool and requires that a corresponding mergetool.<guitool>.cmd variable is\ndefined.\n\no   araxis\n\no   bc\n\no   bc3\n\no   bc4\n\no   codecompare\n\no   deltawalker\n\no   diffmerge\n\no   diffuse\n\no   ecmerge\n\no   emerge\n\no   examdiff\n\no   guiffy\n\no   gvimdiff\n\no   gvimdiff1\n\no   gvimdiff2\n\no   gvimdiff3\n\no   kdiff3\n\no   meld\n\no   nvimdiff\n\no   nvimdiff1\n\no   nvimdiff2\n\no   nvimdiff3\n\no   opendiff\n\no   p4merge\n\no   smerge\n\no   tkdiff\n\no   tortoisemerge\n\no   vimdiff\n\no   vimdiff1\n\no   vimdiff2\n\no   vimdiff3\n\no   winmerge\n\no   xxdiff\n\nmerge.verbosity\nControls the amount of output shown by the recursive merge strategy. Level 0 outputs\nnothing except a final error message if conflicts were detected. Level 1 outputs only\nconflicts, 2 outputs conflicts and file changes. Level 5 and above outputs debugging\ninformation. The default is level 2. Can be overridden by the GITMERGEVERBOSITY\nenvironment variable.\n\nmerge.<driver>.name\nDefines a human-readable name for a custom low-level merge driver. See gitattributes(5)\nfor details.\n\nmerge.<driver>.driver\nDefines the command that implements a custom low-level merge driver. See gitattributes(5)\nfor details.\n\nmerge.<driver>.recursive\nNames a low-level merge driver to be used when performing an internal merge between\ncommon ancestors. See gitattributes(5) for details.\n\nbranch.<name>.mergeOptions\nSets default options for merging into branch <name>. The syntax and supported options are\nthe same as those of git merge, but option values containing whitespace characters are\ncurrently not supported.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "git-fmt-merge-msg(1), git-pull(1), gitattributes(5), git-reset(1), git-diff(1), git-ls-\nfiles(1), git-add(1), git-rm(1), git-mergetool(1)\n",
            "subsections": []
        },
        "GIT": {
            "content": "Part of the git(1) suite\n\nGit 2.34.1                                  02/26/2026                               GIT-MERGE(1)",
            "subsections": []
        }
    },
    "summary": "git-merge - Join two or more development histories together",
    "flags": [
        {
            "flag": "",
            "long": "--no-commit",
            "arg": null,
            "description": "Perform 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, to give the user 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."
        },
        {
            "flag": "-e",
            "long": "--no-edit",
            "arg": null,
            "description": "Invoke an editor before committing successful mechanical merge to further edit the auto-generated merge message, so that the user can explain and justify the merge. The --no-edit option can be used to accept the auto-generated message (this is generally discouraged). The --edit (or -e) option is still useful if you are giving a draft message with the -m option 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 GITMERGEAUTOEDIT 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. See git-commit(1) for more details. In addition, if the <mode> is given a value of scissors, scissors will be appended to MERGEMSG before being passed on to the commit machinery in the case of a merge conflict."
        },
        {
            "flag": "",
            "long": "--ff-only",
            "arg": null,
            "description": "Specifies how a merge is handled when the merged-in history is already a descendant of the current history. --ff is the default unless merging an annotated (and possibly signed) tag that is not stored in its natural place in the refs/tags/ hierarchy, in which case --no-ff is 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. -S[<keyid>], --gpg-sign[=<keyid>], --no-gpg-sign GPG-sign the resulting merge commit. The keyid argument is optional and defaults to the committer identity; if specified, it must be stuck to the option without a space. --no-gpg-sign is useful to countermand both commit.gpgSign configuration 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 also git-fmt-merge-msg(1). With --no-log do not list one-line descriptions from the actual commits being merged."
        },
        {
            "flag": "",
            "long": "--no-signoff",
            "arg": null,
            "description": "Add a Signed-off-by trailer 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. (See http://developercertificate.org for 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."
        },
        {
            "flag": "-n",
            "long": "--no-stat",
            "arg": null,
            "description": "Show a diffstat at the end of the merge. The diffstat is also controlled by the configuration option merge.stat. With -n or --no-stat do not show a diffstat at the end of the merge."
        },
        {
            "flag": "",
            "long": "--no-squash",
            "arg": null,
            "description": "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 the HEAD, or record $GITDIR/MERGEHEAD (to cause the next git commit command 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. --[no-]verify By default, the pre-merge and commit-msg hooks are run. When --no-verify is given, these are bypassed. See also githooks(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 -s option, a built-in list of strategies is used instead (ort when merging a single head, octopus otherwise). -X <option>, --strategy-option=<option> Pass merge strategy specific option through to the merge strategy."
        },
        {
            "flag": "",
            "long": "--no-verify-signatures",
            "arg": null,
            "description": "Verify that the tip commit of the side branch being merged is signed with a valid key, i.e. a key that has a valid uid: 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."
        },
        {
            "flag": "",
            "long": "--no-summary",
            "arg": null,
            "description": "Synonyms to --stat and --no-stat; these are deprecated and will be removed in the future."
        },
        {
            "flag": "-q",
            "long": "--quiet",
            "arg": null,
            "description": "Operate quietly. Implies --no-progress."
        },
        {
            "flag": "-v",
            "long": "--verbose",
            "arg": null,
            "description": "Be verbose."
        },
        {
            "flag": "",
            "long": "--no-progress",
            "arg": null,
            "description": "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."
        },
        {
            "flag": "",
            "long": "--no-autostash",
            "arg": null,
            "description": "Automatically create a temporary stash entry before the operation begins, record it in the special ref MERGEAUTOSTASH and 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."
        },
        {
            "flag": "",
            "long": "--allow-unrelated-histories",
            "arg": null,
            "description": "By default, git merge command 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 and will not be added."
        },
        {
            "flag": "-m",
            "long": null,
            "arg": "<msg>",
            "description": "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. -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."
        },
        {
            "flag": "",
            "long": "--no-rerere-autoupdate",
            "arg": null,
            "description": "Allow the rerere mechanism to update the index with the result of auto-conflict resolution if possible."
        },
        {
            "flag": "",
            "long": "--no-overwrite-ignore",
            "arg": null,
            "description": "Silently overwrite ignored files from the merge result. This is the default behavior. Use --no-overwrite-ignore to abort."
        },
        {
            "flag": "",
            "long": "--abort",
            "arg": null,
            "description": "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 MERGEHEAD is present unless MERGEAUTOSTASH 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."
        },
        {
            "flag": "",
            "long": "--quit",
            "arg": null,
            "description": "Forget about the current merge in progress. Leave the index and the working tree as-is. If MERGEAUTOSTASH is present, the stash entry will be saved to the stash list."
        },
        {
            "flag": "",
            "long": "--continue",
            "arg": null,
            "description": "After a git merge stops due to conflicts you can conclude the merge by running git 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 FETCHHEAD (and no other commit) is specified, the branches recorded in the .git/FETCHHEAD file by the previous invocation of git fetch for merging are merged to the current branch."
        }
    ],
    "examples": [
        "o   Merge branches fixes and enhancements on top of the current branch, making an octopus",
        "merge:",
        "$ git merge fixes enhancements",
        "o   Merge branch obsolete into the current branch, using ours merge strategy:",
        "$ git merge -s ours obsolete",
        "o   Merge branch maint into 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 release/version name would be acceptable."
    ],
    "see_also": [
        {
            "name": "git-fmt-merge-msg",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/git-fmt-merge-msg/1/json"
        },
        {
            "name": "git-pull",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/git-pull/1/json"
        },
        {
            "name": "gitattributes",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/gitattributes/5/json"
        },
        {
            "name": "git-reset",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/git-reset/1/json"
        },
        {
            "name": "git-diff",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/git-diff/1/json"
        },
        {
            "name": "files",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/files/1/json"
        },
        {
            "name": "git-add",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/git-add/1/json"
        },
        {
            "name": "git-rm",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/git-rm/1/json"
        },
        {
            "name": "git-mergetool",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/git-mergetool/1/json"
        }
    ],
    "tldr": {
        "source": "official",
        "description": "Merge branches.",
        "examples": [
            {
                "description": "Merge branches into your current branch",
                "command": "git merge {{branch_name1 branch_name2 ...}}"
            },
            {
                "description": "Edit the merge message",
                "command": "git merge {{-e|--edit}} {{branch_name}}"
            },
            {
                "description": "Merge a branch and create a merge commit",
                "command": "git merge --no-ff {{branch_name}}"
            },
            {
                "description": "Copy the state of a branch into the working tree and stage it (Note: Use `git commit` to create the actual commit)",
                "command": "git merge --squash {{branch_name}}"
            },
            {
                "description": "Abort a merge in case of conflicts",
                "command": "git merge --abort"
            },
            {
                "description": "Merge using a specific strategy",
                "command": "git merge {{-s|--strategy}} {{strategy}} {{-X|--strategy-option}} {{strategy_option}} {{branch_name}}"
            }
        ]
    }
}