[{"data":1,"prerenderedAt":150},["ShallowReactive",2],{"post:cherry-pick-commit-from-detached-head":3},{"id":4,"title":5,"body":6,"date":139,"description":51,"draft":140,"extension":141,"meta":142,"navigation":143,"path":144,"seo":145,"stem":146,"tags":147,"__hash__":149},"posts\u002Fposts\u002Fcherry-pick-commit-from-detached-head.md","TIL: Cherry Pick a Commit from a Detached Head",{"type":7,"value":8,"toc":134},"minimark",[9,14,23,34,38,45,70,85,97,100,107,122,130],[10,11,13],"h2",{"id":12},"the-setup","The Setup",[15,16,17,18,22],"p",{},"I was in a ",[19,20,21],"code",{},"HEAD detached"," state because I was working inside a submodule.",[15,24,25,26,29,30,33],{},"I ran ",[19,27,28],{},"git add"," and ",[19,31,32],{},"git commit"," to record my changes. Then I realized \"No! I'm working in a detached head! How can I \"move\" my commit to the master branch?\"",[10,35,37],{"id":36},"the-fix","The Fix",[15,39,40,41,44],{},"Start by checking out the ",[19,42,43],{},"master"," branch.",[46,47,52],"pre",{"className":48,"code":49,"language":50,"meta":51,"style":51},"language-bash shiki shiki-themes github-light github-dark","git checkout master\n","bash","",[19,53,54],{"__ignoreMap":51},[55,56,59,63,67],"span",{"class":57,"line":58},"line",1,[55,60,62],{"class":61},"sScJk","git",[55,64,66],{"class":65},"sZZnC"," checkout",[55,68,69],{"class":65}," master\n",[15,71,72,73,76,77,84],{},"Then run ",[19,74,75],{},"git reflog"," to ",[78,79,83],"a",{"href":80,"rel":81},"https:\u002F\u002Fstackoverflow.com\u002Fq\u002F17857723",[82],"nofollow","show all branch history, not just the current branch history",".",[46,86,88],{"className":48,"code":87,"language":50,"meta":51,"style":51},"git reflog\n",[19,89,90],{"__ignoreMap":51},[55,91,92,94],{"class":57,"line":58},[55,93,62],{"class":61},[55,95,96],{"class":65}," reflog\n",[15,98,99],{},"Search for the commit you just made. (Should be at the top of the log.)",[15,101,102,103,106],{},"Now ",[19,104,105],{},"cherry-pick"," that commit into the current branch.",[46,108,110],{"className":48,"code":109,"language":50,"meta":51,"style":51},"git cherry-pick 1x3Zy1\n",[19,111,112],{"__ignoreMap":51},[55,113,114,116,119],{"class":57,"line":58},[55,115,62],{"class":61},[55,117,118],{"class":65}," cherry-pick",[55,120,121],{"class":65}," 1x3Zy1\n",[15,123,124,125,129],{},"Done! Hooray, it worked! Thanks to ",[78,126,128],{"href":80,"rel":127},[82],"Stack Overflow"," again.",[131,132,133],"style",{},"html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":51,"searchDepth":135,"depth":135,"links":136},2,[137,138],{"id":12,"depth":135,"text":13},{"id":36,"depth":135,"text":37},"2018-06-01T17:23:06-04:00",false,"md",{},true,"\u002Fposts\u002Fcherry-pick-commit-from-detached-head",{"title":5,"description":51},"posts\u002Fcherry-pick-commit-from-detached-head",[62,148],"til","b3wYcPbLkLZAPek9orCh9pWw7edZU6T5XQodnfosPO0",1790471528128]