Use Theirs With Git Merge | Delft Stack

文章推薦指數: 80 %
投票人數:10人

Use --strategy-option to Resolve Conflicts in Git GitHowtosGitRepositoryNamesSetandSaveUserCredentialsinGitConfigureGitBashWithVisualStudioCodeCreateGroupsandMoveProjectsinGitLabFatal:RefusingtoMergeUnrelatedHistoriesErrorinGitFatal:TheRemoteEndHungUpUnexpectedlyErrorinGitUseGitRebaseontheCommandLineSearchforSpecificStringintheGitCommitHistoryreportthisadHowToGitHowtosUseTheirsWithGitMergeUsethegitmergeCommandWiththeirsinGitUse--strategy-optiontoResolveConflictsinGitUseTemporaryBranchtoMergeinGitWhiledevelopingsoftwarewiththeGittool,youcancreatedifferentbranchesfordifferentfeatures.Buttheremaybeconflictsbetweendifferentbranches.Thisarticlewillexplainusingthegitmergecommandwiththetheirsoptiontoresolveconflicts.UsethegitmergeCommandWiththeirsinGitThegitmergecommandcancombinetwoormoredevelopmenthistories.However,thismergecansometimesnotbedoneduetoconflictsbetweenbranches.Filesinoursortheirsshouldbediscardedtoresolvethisconflict.TheoursreferstotheoriginalworkingbranchwiththeauthorityofGithistory,andthetheirsreferstothebranchthatcontainsthenewappliedcommits.Youcanusethegitmerge-sourstodiscardchangesinours.Thiscommanddiscardsallchangesfromtheotherbranchandleavesthefilesonyourbranchunchanged.Whenyounextmergefromtheotherbranch,Gitwillonlyconsiderchangesmadefromthispointforward.However,the-soptioncannotbeusedwiththeirs.Use--strategy-optiontoResolveConflictsinGitAlternatively,wecanusetheirswiththe-Xor--strategy-optionoption.PleaseenableJavaScriptNotepad++Combineplugin–Combine/MergetwoormorefilesThemaindifferencebetween-Xand-soptionsisthat-Xperformsaregularrecursivemerge,resolvinganyconflictsusingthechosenside,whereas-schangesthemergetojustcompletelyignoretheotherside.Thefollowingcommandresolvesanyconflictsusingthetheirs.gitmerge-Xtheirsbranchname UseTemporaryBranchtoMergeinGitUsethecommandsbelowtomergetest2intocheckedouttest1.Switchtothetest1branch.gitcheckouttest1 Mergethecommitwithoutconflicts.Thecontentsofourswillbediscardedlater.gitmerge-sourstest2 Createatemporarybranch.gitbranchtemp SetHEADwiththegitresetcommand.Itgetscontentsfromthetest2branch.gitreset--hardtest2 Resettomergedcommitbutkeepcontentswiththegitreset--softcommand.gitreset--softtemp Changethemergedcommit’scontentswithtest2’scontents.gitcommit--amend Deletethetemporarybranchwecreatedearlier.gitbranch-Dtemp Youcanseethatthemergedcommitcontainsonlythecontentsoftest2.gitdiffHEADtest2 WriteforusDelftStackarticlesarewrittenbysoftwaregeekslikeyou.IfyoualsowouldliketocontributetoDelftStackbywritingpaidarticles,youcancheckthewriteforuspage.RelatedArticle-GitMergeSelectivelyMergeChangesFromDifferentBranchesinGitMergeFilesWithoutAutoCommitinGitDeleteMergedBranchesinGitUnderstandtheGitConflictMarkersSolveGitPushEverythingUp-To-DateIssueChangetheGitEditorforCommitsreportthisadxx



請為這篇文章評分?