{"id":320,"date":"2018-11-29T17:36:40","date_gmt":"2018-11-29T09:36:40","guid":{"rendered":"https:\/\/fick707.com\/?p=320"},"modified":"2019-05-23T10:59:36","modified_gmt":"2019-05-23T02:59:36","slug":"git-br-delete-rollbak","status":"publish","type":"post","link":"https:\/\/fick707.com\/?p=320","title":{"rendered":"git \u5206\u652f\u5220\u9664\u548cadd commit\u7684\u56de\u6eda"},"content":{"rendered":"<h1 class=\"postTitle\"><a id=\"cb_post_title_url\" class=\"postTitle2\" href=\"https:\/\/www.cnblogs.com\/hqbhonker\/p\/5092300.html\">git \u5220\u9664\u672c\u5730\u5206\u652f\u548c\u8fdc\u7a0b\u5206\u652f\u3001\u672c\u5730\u4ee3\u7801\u56de\u6eda\u548c\u8fdc\u7a0b\u4ee3\u7801\u5e93\u56de\u6eda<\/a><\/h1>\n<p>\u3010git \u5220\u9664\u672c\u5730\u5206\u652f\u3011<\/p>\n<div id=\"articlecontent\">\n<p>git branch -D br<\/p>\n<p>\u3010git \u5220\u9664\u8fdc\u7a0b\u5206\u652f\u3011<\/p>\n<p>git push origin :br \u00a0(origin \u540e\u9762\u6709\u7a7a\u683c)<\/p>\n<p>git\u4ee3\u7801\u5e93\u56de\u6eda: \u6307\u7684\u662f\u5c06\u4ee3\u7801\u5e93\u67d0\u5206\u652f\u9000\u56de\u5230\u4ee5\u524d\u7684\u67d0\u4e2acommit id<\/p>\n<p>\u3010\u672c\u5730\u4ee3\u7801\u5e93add\u56de\u6eda\u3011\uff1a<\/p>\n<p>git status \u5148\u770b\u4e00\u4e0badd \u4e2d\u7684\u6587\u4ef6<br \/>\ngit reset HEAD \u5982\u679c\u540e\u9762\u4ec0\u4e48\u90fd\u4e0d\u8ddf\u7684\u8bdd \u5c31\u662f\u4e0a\u4e00\u6b21add \u91cc\u9762\u7684\u5168\u90e8\u64a4\u9500\u4e86<br \/>\ngit reset HEAD XXX\/XXX\/XXX.java \u5c31\u662f\u5bf9\u67d0\u4e2a\u6587\u4ef6\u8fdb\u884c\u64a4\u9500\u4e86<\/p>\n<p>\u3010\u672c\u5730\u4ee3\u7801\u5e93commit\u56de\u6eda\u3011\uff1a<\/p>\n<p>git reset &#8211;hard commit-id :\u56de\u6eda\u5230commit-id\uff0c\u8bb2commit-id\u4e4b\u540e\u63d0\u4ea4\u7684commit\u90fd\u53bb\u9664<\/p>\n<p>git reset &#8211;hard HEAD~3\uff1a\u5c06\u6700\u8fd13\u6b21\u7684\u63d0\u4ea4\u56de\u6eda<\/p>\n<p>\u3010\u8fdc\u7a0b\u4ee3\u7801\u5e93\u56de\u6eda\u3011\uff1a<\/p>\n<p>\u8fd9\u4e2a\u662f\u91cd\u70b9\u8981\u8bf4\u7684\u5185\u5bb9\uff0c\u8fc7\u7a0b\u6bd4\u672c\u5730\u56de\u6eda\u8981\u590d\u6742<\/p>\n<p>\u5e94\u7528\u573a\u666f\uff1a\u81ea\u52a8\u90e8\u7f72\u7cfb\u7edf\u53d1\u5e03\u540e\u53d1\u73b0\u95ee\u9898\uff0c\u9700\u8981\u56de\u6eda\u5230\u67d0\u4e00\u4e2acommit\uff0c\u518d\u91cd\u65b0\u53d1\u5e03<\/p>\n<p>\u539f\u7406\uff1a\u5148\u5c06\u672c\u5730\u5206\u652f\u9000\u56de\u5230\u67d0\u4e2acommit\uff0c\u5220\u9664\u8fdc\u7a0b\u5206\u652f\uff0c\u518d\u91cd\u65b0push\u672c\u5730\u5206\u652f<\/p>\n<p>\u64cd\u4f5c\u6b65\u9aa4\uff1a<\/p>\n<p>1\u3001git checkout the_branch<\/p>\n<p>2\u3001git pull<\/p>\n<p>3\u3001git branch the_branch_backup \/\/\u5907\u4efd\u4e00\u4e0b\u8fd9\u4e2a\u5206\u652f\u5f53\u524d\u7684\u60c5\u51b5<\/p>\n<p>4\u3001git reset &#8211;hard the_commit_id \/\/\u628athe_branch\u672c\u5730\u56de\u6eda\u5230the_commit_id<\/p>\n<p>5\u3001git push origin :the_branch \/\/\u5220\u9664\u8fdc\u7a0b the_branch<\/p>\n<p>6\u3001git push origin the_branch \/\/\u7528\u56de\u6eda\u540e\u7684\u672c\u5730\u5206\u652f\u91cd\u65b0\u5efa\u7acb\u8fdc\u7a0b\u5206\u652f<\/p>\n<p>7\u3001git push origin :the_branch_backup \/\/\u5982\u679c\u524d\u9762\u90fd\u6210\u529f\u4e86\uff0c\u5220\u9664\u8fd9\u4e2a\u5907\u4efd\u5206\u652f<\/p>\n<p>\u5982\u679c\u4f7f\u7528\u4e86gerrit\u505a\u8fdc\u7a0b\u4ee3\u7801\u4e2d\u5fc3\u5e93\u548ccode review\u5e73\u53f0\uff0c\u9700\u8981\u786e\u4fdd\u64cd\u4f5cgit\u7684\u7528\u6237\u5177\u5907\u5206\u652f\u7684push\u6743\u9650\uff0c\u5e76\u4e14\u9009\u62e9\u4e86 Force Push\u9009\u9879\uff08\u5728push\u6743\u9650\u8bbe\u7f6e\u91cc\u6709\u8fd9\u4e2a\u9009\u9879\uff09<\/p>\n<p>\u53e6\u5916\uff0cgerrit\u4e2d\u5fc3\u5e93\u662f\u4e2abare\u5e93\uff0c\u5c06HEAD\u9ed8\u8ba4\u6307\u5411\u4e86master\uff0c\u56e0\u6b64master\u5206\u652f\u662f\u4e0d\u80fd\u8fdb\u884c\u5220\u9664\u64cd\u4f5c\u7684\uff0c\u6700\u597d\u4e0d\u8981\u9009\u62e9\u5220\u9664master\u5206\u652f\u7684\u7b56\u7565\uff0c\u6362\u7528\u5176\u4ed6\u5206\u652f\u3002\u5982\u679c\u4e00\u5b9a\u8981\u8fd9\u6837\u505a\uff0c\u53ef\u4ee5\u8003\u8651\u5230gerrit\u670d\u52a1\u5668\u4e0a\u4fee\u6539HEAD\u6307\u9488\u3002\u3002\u3002\u4e0d\u5efa\u8bae\u8fd9\u6837\u641e<\/p>\n<p><em>\u8f6c\u8f7d\u81ea\uff1a<a href=\"http:\/\/m.blog.csdn.net\/blog\/lihongli528628\/45483463\" target=\"_blank\" rel=\"noopener noreferrer\"><strong>http:\/\/m.blog.csdn.net\/blog\/lihongli528628\/45483463<\/strong><\/a><\/em><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>git \u5220\u9664\u672c\u5730\u5206\u652f\u548c\u8fdc\u7a0b\u5206\u652f\u3001\u672c\u5730\u4ee3\u7801\u56de\u6eda\u548c\u8fdc\u7a0b\u4ee3\u7801\u5e93\u56de\u6eda \u3010git \u5220\u9664\u672c\u5730\u5206\u652f\u3011 git br &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"series":[],"class_list":["post-320","post","type-post","status-publish","format-standard","hentry","category-programmers"],"_links":{"self":[{"href":"https:\/\/fick707.com\/index.php?rest_route=\/wp\/v2\/posts\/320"}],"collection":[{"href":"https:\/\/fick707.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fick707.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fick707.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fick707.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=320"}],"version-history":[{"count":3,"href":"https:\/\/fick707.com\/index.php?rest_route=\/wp\/v2\/posts\/320\/revisions"}],"predecessor-version":[{"id":573,"href":"https:\/\/fick707.com\/index.php?rest_route=\/wp\/v2\/posts\/320\/revisions\/573"}],"wp:attachment":[{"href":"https:\/\/fick707.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=320"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fick707.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=320"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fick707.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=320"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/fick707.com\/index.php?rest_route=%2Fwp%2Fv2%2Fseries&post=320"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}