The second syntax (" git merge --abort ") can only be run after the merge has resulted in conflicts. git merge --abort will abort the merge process and try ...
About
BranchingandMerging
SmallandFast
Distributed
DataAssurance
StagingArea
FreeandOpenSource
Trademark
Documentation
Reference
Book
Videos
ExternalLinks
Downloads
GUIClients
Logos
Community
English▾
English
Français
Português(Brasil)
Topics▾
SetupandConfig
git
config
help
bugreport
GettingandCreatingProjects
init
clone
BasicSnapshotting
add
status
diff
commit
notes
restore
reset
rm
mv
BranchingandMerging
branch
checkout
switch
merge
mergetool
log
stash
tag
worktree
SharingandUpdatingProjects
fetch
pull
push
remote
submodule
InspectionandComparison
show
log
diff
difftool
range-diff
shortlog
describe
Patching
apply
cherry-pick
diff
rebase
revert
Debugging
bisect
blame
grep
Email
am
apply
format-patch
send-email
request-pull
ExternalSystems
svn
fast-import
ServerAdmin
daemon
update-server-info
Guides
gitattributes
Command-lineinterfaceconventions
EverydayGit
FrequentlyAskedQuestions(FAQ)
Glossary
Hooks
gitignore
gitmodules
Revisions
Submodules
Tutorial
Workflows
Allguides...
Administration
clean
gc
fsck
reflog
filter-branch
instaweb
archive
bundle
PlumbingCommands
cat-file
check-ignore
checkout-index
commit-tree
count-objects
diff-index
for-each-ref
hash-object
ls-files
ls-tree
merge-base
read-tree
rev-list
rev-parse
show-ref
symbolic-ref
update-index
update-ref
verify-pack
write-tree
Version2.37.2
▾
git-mergelastupdatedin2.37.2
2.35.1→2.37.2nochanges
2.35.0
01/24/22
2.34.1→2.34.4nochanges
2.34.0
11/15/21
2.33.2→2.33.4nochanges
2.33.1
10/12/21
2.33.0
08/16/21
2.30.1→2.32.3nochanges
2.30.0
12/27/20
2.29.1→2.29.3nochanges
2.29.0
10/19/20
2.27.1→2.28.1nochanges
2.27.0
06/01/20
2.25.1→2.26.3nochanges
2.25.0
01/13/20
2.24.1→2.24.4nochanges
2.24.0
11/04/19
2.23.1→2.23.4nochanges
2.23.0
08/16/19
2.22.2→2.22.5nochanges
2.22.1
08/11/19
2.22.0
06/07/19
2.20.1→2.21.4nochanges
2.20.0
12/09/18
2.19.1→2.19.6nochanges
2.19.0
09/10/18
2.18.1→2.18.5nochanges
2.18.0
06/21/18
NAME
git-merge-Jointwoormoredevelopmenthistoriestogether
SYNOPSIS
gitmerge[-n][--stat][--no-commit][--squash][--[no-]edit]
[--no-verify][-s][-X][-S[]]
[--[no-]allow-unrelated-histories]
[--[no-]rerere-autoupdate][-m][-F]
[--into-name][…]
gitmerge(--continue|--abort|--quit)
DESCRIPTION
Incorporateschangesfromthenamedcommits(sincethetimetheir
historiesdivergedfromthecurrentbranch)intothecurrent
branch.Thiscommandisusedbygitpulltoincorporatechanges
fromanotherrepositoryandcanbeusedbyhandtomergechanges
fromonebranchintoanother.
Assumethefollowinghistoryexistsandthecurrentbranchis
"master":
A---B---Ctopic
/
D---E---F---Gmaster
Then"gitmergetopic"willreplaythechangesmadeonthe
topicbranchsinceitdivergedfrommaster(i.e.,E)until
itscurrentcommit(C)ontopofmaster,andrecordtheresult
inanewcommitalongwiththenamesofthetwoparentcommitsand
alogmessagefromtheuserdescribingthechanges.
A---B---Ctopic
/\
D---E---F---G---Hmaster
Thesecondsyntax("gitmerge--abort")canonlyberunafterthe
mergehasresultedinconflicts.gitmerge--abortwillabortthe
mergeprocessandtrytoreconstructthepre-mergestate.However,
iftherewereuncommittedchangeswhenthemergestarted(and
especiallyifthosechangeswerefurthermodifiedafterthemerge
wasstarted),gitmerge--abortwillinsomecasesbeunableto
reconstructtheoriginal(pre-merge)changes.Therefore:
Warning:Runninggitmergewithnon-trivialuncommittedchangesis
discouraged:whilepossible,itmayleaveyouinastatethatishardto
backoutofinthecaseofaconflict.
Thethirdsyntax("gitmerge--continue")canonlyberunafterthe
mergehasresultedinconflicts.
OPTIONS
--commit
--no-commit
Performthemergeandcommittheresult.Thisoptioncan
beusedtooverride--no-commit.
With--no-commitperformthemergeandstopjustbeforecreating
amergecommit,togivetheuserachancetoinspectandfurther
tweakthemergeresultbeforecommitting.
Notethatfast-forwardupdatesdonotcreateamergecommitand
thereforethereisnowaytostopthosemergeswith--no-commit.
Thus,ifyouwanttoensureyourbranchisnotchangedorupdated
bythemergecommand,use--no-ffwith--no-commit.
--edit
-e
--no-edit
Invokeaneditorbeforecommittingsuccessfulmechanicalmergeto
furtheredittheauto-generatedmergemessage,sothattheuser
canexplainandjustifythemerge.The--no-editoptioncanbe
usedtoaccepttheauto-generatedmessage(thisisgenerally
discouraged).
The--edit(or-e)optionisstillusefulifyouare
givingadraftmessagewiththe-moptionfromthecommandline
andwanttoedititintheeditor.
Olderscriptsmaydependonthehistoricalbehaviourofnotallowingthe
usertoeditthemergelogmessage.Theywillseeaneditoropenedwhen
theyrungitmerge.Tomakeiteasiertoadjustsuchscriptstothe
updatedbehaviour,theenvironmentvariableGIT_MERGE_AUTOEDITcanbe
settonoatthebeginningofthem.
--cleanup=
Thisoptiondetermineshowthemergemessagewillbecleanedupbefore
committing.Seegit-commit[1]formoredetails.Inaddition,if
theisgivenavalueofscissors,scissorswillbeappended
toMERGE_MSGbeforebeingpassedontothecommitmachineryinthe
caseofamergeconflict.
--ff
--no-ff
--ff-only
Specifieshowamergeishandledwhenthemerged-inhistoryis
alreadyadescendantofthecurrenthistory.--ffisthe
defaultunlessmerginganannotated(andpossiblysigned)tag
thatisnotstoredinitsnaturalplaceintherefs/tags/
hierarchy,inwhichcase--no-ffisassumed.
With--ff,whenpossibleresolvethemergeasafast-forward(only
updatethebranchpointertomatchthemergedbranch;donotcreatea
mergecommit).Whennotpossible(whenthemerged-inhistoryisnota
descendantofthecurrenthistory),createamergecommit.
With--no-ff,createamergecommitinallcases,evenwhenthemerge
couldinsteadberesolvedasafast-forward.
With--ff-only,resolvethemergeasafast-forwardwhenpossible.
Whennotpossible,refusetomergeandexitwithanon-zerostatus.
-S[]
--gpg-sign[=]
--no-gpg-sign
GPG-signtheresultingmergecommit.Thekeyidargumentis
optionalanddefaultstothecommitteridentity;ifspecified,
itmustbestucktotheoptionwithoutaspace.--no-gpg-sign
isusefultocountermandbothcommit.gpgSignconfigurationvariable,
andearlier--gpg-sign.
--log[=]
--no-log
Inadditiontobranchnames,populatethelogmessagewith
one-linedescriptionsfromatmostactualcommitsthatarebeing
merged.Seealsogit-fmt-merge-msg[1].
With--no-logdonotlistone-linedescriptionsfromthe
actualcommitsbeingmerged.
--signoff
--no-signoff
AddaSigned-off-bytrailerbythecommitterattheendofthecommit
logmessage.Themeaningofasignoffdependsontheproject
towhichyou’recommitting.Forexample,itmaycertifythat
thecommitterhastherightstosubmittheworkunderthe
project’slicenseoragreestosomecontributorrepresentation,
suchasaDeveloperCertificateofOrigin.
(Seehttp://developercertificate.orgfortheoneusedbythe
LinuxkernelandGitprojects.)Consultthedocumentationor
leadershipoftheprojecttowhichyou’recontributingto
understandhowthesignoffsareusedinthatproject.
The--no-signoffoptioncanbeusedtocountermandanearlier--signoff
optiononthecommandline.
--stat
-n
--no-stat
Showadiffstatattheendofthemerge.Thediffstatisalso
controlledbytheconfigurationoptionmerge.stat.
With-nor--no-statdonotshowadiffstatattheendofthe
merge.
--squash
--no-squash
Producetheworkingtreeandindexstateasifarealmerge
happened(exceptforthemergeinformation),butdonotactually
makeacommit,movetheHEAD,orrecord$GIT_DIR/MERGE_HEAD
(tocausethenextgitcommitcommandtocreateamerge
commit).Thisallowsyoutocreateasinglecommitontopof
thecurrentbranchwhoseeffectisthesameasmerginganother
branch(ormoreincaseofanoctopus).
With--no-squashperformthemergeandcommittheresult.This
optioncanbeusedtooverride--squash.
With--squash,--commitisnotallowed,andwillfail.
--[no-]verify
Bydefault,thepre-mergeandcommit-msghooksarerun.
When--no-verifyisgiven,thesearebypassed.
Seealsogithooks[5].
-s
--strategy=
Usethegivenmergestrategy;canbesuppliedmorethan
oncetospecifythemintheordertheyshouldbetried.
Ifthereisno-soption,abuilt-inlistofstrategies
isusedinstead(ortwhenmergingasinglehead,
octopusotherwise).
-X