[{"data":1,"prerenderedAt":164},["ShallowReactive",2],{"\u002Fblog\u002Frevert-full-commit":3},{"id":4,"title":5,"body":6,"date":153,"description":154,"extension":155,"image":156,"meta":157,"navigation":117,"path":158,"seo":159,"stem":160,"tags":161,"__hash__":163},"blog\u002Fblog\u002Frevert-full-commit.md","Revert the full commit",{"type":7,"value":8,"toc":148},"minimark",[9,13,39,44,49,60,78,93,131,134,144],[10,11,12],"p",{},"Sometimes you may want to undo a whole commit with all changes. Instead of going through all the changes manually, you can simply tell git to revert a commit, which does not even have to be the last one. Reverting a commit means to create a new commit that undoes all changes that were made in the bad commit. Just like above, the bad commit remains there, but it no longer affects the the current master and any future commits on top of it.",[14,15,20],"pre",{"className":16,"code":17,"language":18,"meta":19,"style":19},"language-shell shiki shiki-themes github-light github-dark","git revert {commit_id}\n","shell","",[21,22,23],"code",{"__ignoreMap":19},[24,25,28,32,36],"span",{"class":26,"line":27},"line",1,[24,29,31],{"class":30},"sScJk","git",[24,33,35],{"class":34},"sZZnC"," revert",[24,37,38],{"class":34}," {commit_id}\n",[40,41,43],"h2",{"id":42},"about-history-rewriting","About History Rewriting",[45,46,48],"h3",{"id":47},"delete-the-last-commit","Delete the last commit",[10,50,51,52,56,57,59],{},"Deleting the last commit is the easiest case.\nLet's say we have a remote origin with branch master that currently points to commit ",[53,54,55],"em",{},"dd61ab32",".\nWe want to remove the top commit. Translated to git terminology, we want to force the master branch of the origin remote repository to the parent of ",[53,58,55],{},":",[14,61,63],{"className":16,"code":62,"language":18,"meta":19,"style":19},"git push origin +dd61ab32^:master\n",[21,64,65],{"__ignoreMap":19},[24,66,67,69,72,75],{"class":26,"line":27},[24,68,31],{"class":30},[24,70,71],{"class":34}," push",[24,73,74],{"class":34}," origin",[24,76,77],{"class":34}," +dd61ab32^:master\n",[10,79,80,81,84,85,88,89,92],{},"Where git interprets ",[21,82,83],{},"x^"," as the parent of ",[21,86,87],{},"x"," and ",[21,90,91],{},"+"," as a forced non-fastforward push.\nIf you have the master branch checked out locally, you can also do it in two simpler steps: First reset the branch to the parent of the current commit, then force-push it to the remote.",[14,94,96],{"className":16,"code":95,"language":18,"meta":19,"style":19},"git reset HEAD^ --hard\n\ngit push origin -f\n",[21,97,98,112,119],{"__ignoreMap":19},[24,99,100,102,105,108],{"class":26,"line":27},[24,101,31],{"class":30},[24,103,104],{"class":34}," reset",[24,106,107],{"class":34}," HEAD^",[24,109,111],{"class":110},"sj4cs"," --hard\n",[24,113,115],{"class":26,"line":114},2,[24,116,118],{"emptyLinePlaceholder":117},true,"\n",[24,120,122,124,126,128],{"class":26,"line":121},3,[24,123,31],{"class":30},[24,125,71],{"class":34},[24,127,74],{"class":34},[24,129,130],{"class":110}," -f\n",[132,133],"hr",{},[10,135,136,137,143],{},"This document is inspired by ",[138,139,140],"a",{"href":140,"rel":141},"http:\u002F\u002Fchristoph.ruegg.name\u002Fblog\u002Fgit-howto-revert-a-commit-already-pushed-to-a-remote-reposit.html",[142],"nofollow"," - Thank you.",[145,146,147],"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);}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}",{"title":19,"searchDepth":114,"depth":114,"links":149},[150],{"id":42,"depth":114,"text":43,"children":151},[152],{"id":47,"depth":121,"text":48},"2023-04-02","Sometimes you may want to undo a whole commit with all changes. Git revert creates a new commit that undoes the bad one — clean, safe, and collaborative.","md","https:\u002F\u002Fimages.unsplash.com\u002Fphoto-1647166545674-ce28ce93bdca?auto=format&fit=crop&w=600&q=80",{},"\u002Fblog\u002Frevert-full-commit",{"title":5,"description":154},"blog\u002Frevert-full-commit",[162],"Git","W6tN31GJqSA-z0ZYyHkDOEuKiR5SYUj0UZBGqCTL0Xg",1777082696607]