[{"data":1,"prerenderedAt":-1},["Reactive",2],{"content-/articles/general/git-cherrypick":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"_empty":6,"title":8,"description":9,"excerpt":10,"topic":21,"authors":22,"tags":26,"updatedAt":30,"createdAt":30,"body":31,"_type":735,"_id":736,"_source":737,"_file":738,"_extension":739},"/articles/general/git-cherrypick","general",false,"","Git Cherrypick","A way of duplicate commits cross branch without manual copy-paste",{"type":11,"children":12},"root",[13],{"type":14,"tag":15,"props":16,"children":17},"element","p",{},[18],{"type":19,"value":20},"text","Git Cherrypick is a feature that allows us to copy a specific commit from one branch to the other without needing to merge the two branch together.","General",[23],{"name":24,"avatar":25},"Shaun Chong","levi.png",[27,28,29],"git","workflow","commit","2026-05-17T12:24:00.000Z",{"type":11,"children":32,"toc":729},[33,37,46,73,80,92,104,152,177,272,284,368,374,392,489,495,500,703,709,717,724],{"type":14,"tag":15,"props":34,"children":35},{},[36],{"type":19,"value":20},{"type":14,"tag":15,"props":38,"children":39},{},[40],{"type":14,"tag":41,"props":42,"children":45},"img",{"alt":43,"src":44},"Git Cherrypick Overview","/images/git-cherrypick/git_cherrypick_overview.svg",[],{"type":14,"tag":15,"props":47,"children":48},{},[49,51,57,59,64,66,71],{"type":19,"value":50},"The diagram above illustrates the intention to move the ",{"type":14,"tag":52,"props":53,"children":54},"code-inline",{},[55],{"type":19,"value":56},"C",{"type":19,"value":58}," commit from ",{"type":14,"tag":52,"props":60,"children":61},{},[62],{"type":19,"value":63},"feature",{"type":19,"value":65}," branch to ",{"type":14,"tag":52,"props":67,"children":68},{},[69],{"type":19,"value":70},"C'",{"type":19,"value":72}," in main branch. Cherry-pick creates a new commit hash instead of moving the commit with metadata one-to-one.",{"type":14,"tag":74,"props":75,"children":77},"h2",{"id":76},"basic-usage",[78],{"type":19,"value":79},"Basic Usage",{"type":14,"tag":15,"props":81,"children":82},{},[83,85,90],{"type":19,"value":84},"This is helpful when we have committed wrongly to the main branch, while we should commit to the feature branch ",{"type":14,"tag":52,"props":86,"children":87},{},[88],{"type":19,"value":89},"feat/awesome-feature",{"type":19,"value":91}," instead.",{"type":14,"tag":15,"props":93,"children":94},{},[95,97,102],{"type":19,"value":96},"In this case, grab the hash for the commit in the ",{"type":14,"tag":52,"props":98,"children":99},{},[100],{"type":19,"value":101},"main",{"type":19,"value":103}," branch first.",{"type":14,"tag":105,"props":106,"children":111},"code",{"className":107,"code":109,"language":110,"meta":7},[108],"language-sh","git log --oneline\n","sh",[112],{"type":14,"tag":113,"props":114,"children":115},"pre",{},[116],{"type":14,"tag":105,"props":117,"children":118},{"__ignoreMap":7},[119],{"type":14,"tag":120,"props":121,"children":124},"span",{"class":122,"line":123},"line",1,[125,130,136,142,146],{"type":14,"tag":120,"props":126,"children":128},{"class":127},"ct-255010",[129],{"type":19,"value":27},{"type":14,"tag":120,"props":131,"children":133},{"class":132},"ct-947867",[134],{"type":19,"value":135}," ",{"type":14,"tag":120,"props":137,"children":139},{"class":138},"ct-094461",[140],{"type":19,"value":141},"log",{"type":14,"tag":120,"props":143,"children":144},{"class":132},[145],{"type":19,"value":135},{"type":14,"tag":120,"props":147,"children":149},{"class":148},"ct-642681",[150],{"type":19,"value":151},"--oneline",{"type":14,"tag":15,"props":153,"children":154},{},[155,157,161,163,168,170,175],{"type":19,"value":156},"Then copy the hash and checkout to the ",{"type":14,"tag":52,"props":158,"children":159},{},[160],{"type":19,"value":89},{"type":19,"value":162}," branch. Finally, just use the ",{"type":14,"tag":52,"props":164,"children":165},{},[166],{"type":19,"value":167},"git cherry-pick",{"type":19,"value":169}," command and provide the ",{"type":14,"tag":52,"props":171,"children":172},{},[173],{"type":19,"value":174},"hash",{"type":19,"value":176}," copied as the argument.",{"type":14,"tag":105,"props":178,"children":181},{"className":179,"code":180,"language":110,"meta":7},[108],"git checkout feat/awesome-feature\ngit cherry-pick \u003Cthe commit hash>\n",[182],{"type":14,"tag":113,"props":183,"children":184},{},[185],{"type":14,"tag":105,"props":186,"children":187},{"__ignoreMap":7},[188,213],{"type":14,"tag":120,"props":189,"children":190},{"class":122,"line":123},[191,195,199,204,208],{"type":14,"tag":120,"props":192,"children":193},{"class":127},[194],{"type":19,"value":27},{"type":14,"tag":120,"props":196,"children":197},{"class":132},[198],{"type":19,"value":135},{"type":14,"tag":120,"props":200,"children":201},{"class":138},[202],{"type":19,"value":203},"checkout",{"type":14,"tag":120,"props":205,"children":206},{"class":132},[207],{"type":19,"value":135},{"type":14,"tag":120,"props":209,"children":210},{"class":138},[211],{"type":19,"value":212},"feat/awesome-feature\n",{"type":14,"tag":120,"props":214,"children":216},{"class":122,"line":215},2,[217,221,225,230,234,240,245,249,253,257,262,267],{"type":14,"tag":120,"props":218,"children":219},{"class":127},[220],{"type":19,"value":27},{"type":14,"tag":120,"props":222,"children":223},{"class":132},[224],{"type":19,"value":135},{"type":14,"tag":120,"props":226,"children":227},{"class":138},[228],{"type":19,"value":229},"cherry-pick",{"type":14,"tag":120,"props":231,"children":232},{"class":132},[233],{"type":19,"value":135},{"type":14,"tag":120,"props":235,"children":237},{"class":236},"ct-620894",[238],{"type":19,"value":239},"\u003C",{"type":14,"tag":120,"props":241,"children":242},{"class":138},[243],{"type":19,"value":244},"the",{"type":14,"tag":120,"props":246,"children":247},{"class":132},[248],{"type":19,"value":135},{"type":14,"tag":120,"props":250,"children":251},{"class":138},[252],{"type":19,"value":29},{"type":14,"tag":120,"props":254,"children":255},{"class":132},[256],{"type":19,"value":135},{"type":14,"tag":120,"props":258,"children":259},{"class":138},[260],{"type":19,"value":261},"has",{"type":14,"tag":120,"props":263,"children":264},{"class":132},[265],{"type":19,"value":266},"h",{"type":14,"tag":120,"props":268,"children":269},{"class":236},[270],{"type":19,"value":271},">",{"type":14,"tag":15,"props":273,"children":274},{},[275,277,282],{"type":19,"value":276},"This should successfully copied over the commit without manually working on this. After that, checkout main and remove the accidental commit using ",{"type":14,"tag":52,"props":278,"children":279},{},[280],{"type":19,"value":281},"git reset",{"type":19,"value":283},".",{"type":14,"tag":105,"props":285,"children":288},{"className":286,"code":287,"language":110,"meta":7},[108],"git checkout main\ngit reset --hard HEAD~1 # remove commit from main\n",[289],{"type":14,"tag":113,"props":290,"children":291},{},[292],{"type":14,"tag":105,"props":293,"children":294},{"__ignoreMap":7},[295,319],{"type":14,"tag":120,"props":296,"children":297},{"class":122,"line":123},[298,302,306,310,314],{"type":14,"tag":120,"props":299,"children":300},{"class":127},[301],{"type":19,"value":27},{"type":14,"tag":120,"props":303,"children":304},{"class":132},[305],{"type":19,"value":135},{"type":14,"tag":120,"props":307,"children":308},{"class":138},[309],{"type":19,"value":203},{"type":14,"tag":120,"props":311,"children":312},{"class":132},[313],{"type":19,"value":135},{"type":14,"tag":120,"props":315,"children":316},{"class":138},[317],{"type":19,"value":318},"main\n",{"type":14,"tag":120,"props":320,"children":321},{"class":122,"line":215},[322,326,330,335,339,344,348,353,358,362],{"type":14,"tag":120,"props":323,"children":324},{"class":127},[325],{"type":19,"value":27},{"type":14,"tag":120,"props":327,"children":328},{"class":132},[329],{"type":19,"value":135},{"type":14,"tag":120,"props":331,"children":332},{"class":138},[333],{"type":19,"value":334},"reset",{"type":14,"tag":120,"props":336,"children":337},{"class":132},[338],{"type":19,"value":135},{"type":14,"tag":120,"props":340,"children":341},{"class":148},[342],{"type":19,"value":343},"--hard",{"type":14,"tag":120,"props":345,"children":346},{"class":132},[347],{"type":19,"value":135},{"type":14,"tag":120,"props":349,"children":350},{"class":138},[351],{"type":19,"value":352},"HEAD~",{"type":14,"tag":120,"props":354,"children":355},{"class":148},[356],{"type":19,"value":357},"1",{"type":14,"tag":120,"props":359,"children":360},{"class":132},[361],{"type":19,"value":135},{"type":14,"tag":120,"props":363,"children":365},{"class":364},"ct-463487",[366],{"type":19,"value":367},"# remove commit from main",{"type":14,"tag":74,"props":369,"children":371},{"id":370},"no-commit",[372],{"type":19,"value":373},"No Commit",{"type":14,"tag":15,"props":375,"children":376},{},[377,379,384,386,391],{"type":19,"value":378},"Sometimes, it is helpful if we want to copy over the commit and make some changes first without commiting directly. In this case, use the ",{"type":14,"tag":52,"props":380,"children":381},{},[382],{"type":19,"value":383},"-n",{"type":19,"value":385}," flag that is short for ",{"type":14,"tag":52,"props":387,"children":388},{},[389],{"type":19,"value":390},"--no-commit",{"type":19,"value":283},{"type":14,"tag":105,"props":393,"children":396},{"className":394,"code":395,"language":110,"meta":7},[108],"git cherry-pick -n \u003Chash>\n# make some tweaks...\ngit commit -m \"Applied fix with adjustments\"\n",[397],{"type":14,"tag":113,"props":398,"children":399},{},[400],{"type":14,"tag":105,"props":401,"children":402},{"__ignoreMap":7},[403,447,455],{"type":14,"tag":120,"props":404,"children":405},{"class":122,"line":123},[406,410,414,418,422,426,430,434,438,442],{"type":14,"tag":120,"props":407,"children":408},{"class":127},[409],{"type":19,"value":27},{"type":14,"tag":120,"props":411,"children":412},{"class":132},[413],{"type":19,"value":135},{"type":14,"tag":120,"props":415,"children":416},{"class":138},[417],{"type":19,"value":229},{"type":14,"tag":120,"props":419,"children":420},{"class":132},[421],{"type":19,"value":135},{"type":14,"tag":120,"props":423,"children":424},{"class":148},[425],{"type":19,"value":383},{"type":14,"tag":120,"props":427,"children":428},{"class":132},[429],{"type":19,"value":135},{"type":14,"tag":120,"props":431,"children":432},{"class":236},[433],{"type":19,"value":239},{"type":14,"tag":120,"props":435,"children":436},{"class":138},[437],{"type":19,"value":261},{"type":14,"tag":120,"props":439,"children":440},{"class":132},[441],{"type":19,"value":266},{"type":14,"tag":120,"props":443,"children":444},{"class":236},[445],{"type":19,"value":446},">\n",{"type":14,"tag":120,"props":448,"children":449},{"class":122,"line":215},[450],{"type":14,"tag":120,"props":451,"children":452},{"class":364},[453],{"type":19,"value":454},"# make some tweaks...\n",{"type":14,"tag":120,"props":456,"children":458},{"class":122,"line":457},3,[459,463,467,471,475,480,484],{"type":14,"tag":120,"props":460,"children":461},{"class":127},[462],{"type":19,"value":27},{"type":14,"tag":120,"props":464,"children":465},{"class":132},[466],{"type":19,"value":135},{"type":14,"tag":120,"props":468,"children":469},{"class":138},[470],{"type":19,"value":29},{"type":14,"tag":120,"props":472,"children":473},{"class":132},[474],{"type":19,"value":135},{"type":14,"tag":120,"props":476,"children":477},{"class":148},[478],{"type":19,"value":479},"-m",{"type":14,"tag":120,"props":481,"children":482},{"class":132},[483],{"type":19,"value":135},{"type":14,"tag":120,"props":485,"children":486},{"class":138},[487],{"type":19,"value":488},"\"Applied fix with adjustments\"",{"type":14,"tag":74,"props":490,"children":492},{"id":491},"handling-conflicts",[493],{"type":19,"value":494},"Handling Conflicts",{"type":14,"tag":15,"props":496,"children":497},{},[498],{"type":19,"value":499},"Cherry-pick can still face conflicts just like merging does. In that case, we can resolve it manually and then continue or abandon the cherry-pick process.",{"type":14,"tag":105,"props":501,"children":504},{"className":502,"code":503,"language":110,"meta":7},[108],"git cherry-pick \u003Chash>\n# CONFLICT! git pauses here\n\n# 1. Fix the conflicting files\n# 2. Stage them\ngit add \u003Cfixed-files>\n\n# 3. Continue the cherry-pick\ngit cherry-pick --continue\n\n# OR, abandon it\ngit cherry-pick --abort\n",[505],{"type":14,"tag":113,"props":506,"children":507},{},[508],{"type":14,"tag":105,"props":509,"children":510},{"__ignoreMap":7},[511,546,554,562,571,580,619,627,636,661,669,678],{"type":14,"tag":120,"props":512,"children":513},{"class":122,"line":123},[514,518,522,526,530,534,538,542],{"type":14,"tag":120,"props":515,"children":516},{"class":127},[517],{"type":19,"value":27},{"type":14,"tag":120,"props":519,"children":520},{"class":132},[521],{"type":19,"value":135},{"type":14,"tag":120,"props":523,"children":524},{"class":138},[525],{"type":19,"value":229},{"type":14,"tag":120,"props":527,"children":528},{"class":132},[529],{"type":19,"value":135},{"type":14,"tag":120,"props":531,"children":532},{"class":236},[533],{"type":19,"value":239},{"type":14,"tag":120,"props":535,"children":536},{"class":138},[537],{"type":19,"value":261},{"type":14,"tag":120,"props":539,"children":540},{"class":132},[541],{"type":19,"value":266},{"type":14,"tag":120,"props":543,"children":544},{"class":236},[545],{"type":19,"value":446},{"type":14,"tag":120,"props":547,"children":548},{"class":122,"line":215},[549],{"type":14,"tag":120,"props":550,"children":551},{"class":364},[552],{"type":19,"value":553},"# CONFLICT! git pauses here\n",{"type":14,"tag":120,"props":555,"children":556},{"class":122,"line":457},[557],{"type":14,"tag":120,"props":558,"children":559},{},[560],{"type":19,"value":561},"\n",{"type":14,"tag":120,"props":563,"children":565},{"class":122,"line":564},4,[566],{"type":14,"tag":120,"props":567,"children":568},{"class":364},[569],{"type":19,"value":570},"# 1. Fix the conflicting files\n",{"type":14,"tag":120,"props":572,"children":574},{"class":122,"line":573},5,[575],{"type":14,"tag":120,"props":576,"children":577},{"class":364},[578],{"type":19,"value":579},"# 2. Stage them\n",{"type":14,"tag":120,"props":581,"children":583},{"class":122,"line":582},6,[584,588,592,597,601,605,610,615],{"type":14,"tag":120,"props":585,"children":586},{"class":127},[587],{"type":19,"value":27},{"type":14,"tag":120,"props":589,"children":590},{"class":132},[591],{"type":19,"value":135},{"type":14,"tag":120,"props":593,"children":594},{"class":138},[595],{"type":19,"value":596},"add",{"type":14,"tag":120,"props":598,"children":599},{"class":132},[600],{"type":19,"value":135},{"type":14,"tag":120,"props":602,"children":603},{"class":236},[604],{"type":19,"value":239},{"type":14,"tag":120,"props":606,"children":607},{"class":138},[608],{"type":19,"value":609},"fixed-file",{"type":14,"tag":120,"props":611,"children":612},{"class":132},[613],{"type":19,"value":614},"s",{"type":14,"tag":120,"props":616,"children":617},{"class":236},[618],{"type":19,"value":446},{"type":14,"tag":120,"props":620,"children":622},{"class":122,"line":621},7,[623],{"type":14,"tag":120,"props":624,"children":625},{},[626],{"type":19,"value":561},{"type":14,"tag":120,"props":628,"children":630},{"class":122,"line":629},8,[631],{"type":14,"tag":120,"props":632,"children":633},{"class":364},[634],{"type":19,"value":635},"# 3. Continue the cherry-pick\n",{"type":14,"tag":120,"props":637,"children":639},{"class":122,"line":638},9,[640,644,648,652,656],{"type":14,"tag":120,"props":641,"children":642},{"class":127},[643],{"type":19,"value":27},{"type":14,"tag":120,"props":645,"children":646},{"class":132},[647],{"type":19,"value":135},{"type":14,"tag":120,"props":649,"children":650},{"class":138},[651],{"type":19,"value":229},{"type":14,"tag":120,"props":653,"children":654},{"class":132},[655],{"type":19,"value":135},{"type":14,"tag":120,"props":657,"children":658},{"class":148},[659],{"type":19,"value":660},"--continue\n",{"type":14,"tag":120,"props":662,"children":664},{"class":122,"line":663},10,[665],{"type":14,"tag":120,"props":666,"children":667},{},[668],{"type":19,"value":561},{"type":14,"tag":120,"props":670,"children":672},{"class":122,"line":671},11,[673],{"type":14,"tag":120,"props":674,"children":675},{"class":364},[676],{"type":19,"value":677},"# OR, abandon it\n",{"type":14,"tag":120,"props":679,"children":681},{"class":122,"line":680},12,[682,686,690,694,698],{"type":14,"tag":120,"props":683,"children":684},{"class":127},[685],{"type":19,"value":27},{"type":14,"tag":120,"props":687,"children":688},{"class":132},[689],{"type":19,"value":135},{"type":14,"tag":120,"props":691,"children":692},{"class":138},[693],{"type":19,"value":229},{"type":14,"tag":120,"props":695,"children":696},{"class":132},[697],{"type":19,"value":135},{"type":14,"tag":120,"props":699,"children":700},{"class":148},[701],{"type":19,"value":702},"--abort",{"type":14,"tag":74,"props":704,"children":706},{"id":705},"reference",[707],{"type":19,"value":708},"Reference",{"type":14,"tag":710,"props":711,"children":716},"apa-reference",{"source":712,"title":713,"url":714,"date":715},"websites","git-cherry-pick","https://git-scm.com/docs/git-cherry-pick","2026, April 20",[],{"type":14,"tag":710,"props":718,"children":723},{"source":712,"title":719,"url":720,"publisher":721,"retrievedDate":722},"Git cherry pick","https://www.atlassian.com/git/tutorials/cherry-pick","Atlassian","2026, May 17",[],{"type":14,"tag":725,"children":726},"style",[727],{"type":19,"value":728},".ct-255010{color:#953800;}\n.dark .ct-255010{color:#FFA657;}\n.ct-947867{color:#24292F;}\n.dark .ct-947867{color:#C9D1D9;}\n.ct-094461{color:#0A3069;}\n.dark .ct-094461{color:#A5D6FF;}\n.ct-642681{color:#0550AE;}\n.dark .ct-642681{color:#79C0FF;}\n.ct-620894{color:#CF222E;}\n.dark .ct-620894{color:#FF7B72;}\n.ct-463487{color:#6E7781;}\n.dark .ct-463487{color:#8B949E;}",{"title":7,"searchDepth":215,"depth":215,"links":730},[731,732,733,734],{"id":76,"depth":215,"text":79},{"id":370,"depth":215,"text":373},{"id":491,"depth":215,"text":494},{"id":705,"depth":215,"text":708},"markdown","content:articles:general:git-cherrypick.md","content","articles/general/git-cherrypick.md","md"]