{"id":20390,"date":"2024-11-19T15:13:57","date_gmt":"2024-11-19T07:13:57","guid":{"rendered":"https:\/\/fwq.ai\/blog\/20390\/"},"modified":"2024-11-19T15:13:57","modified_gmt":"2024-11-19T07:13:57","slug":"%e5%a6%82%e4%bd%95%e5%88%a9%e7%94%a8gitlab%e8%bf%9b%e8%a1%8c%e9%a1%b9%e7%9b%ae%e7%89%88%e6%9c%ac%e5%8f%91%e5%b8%83%e5%92%8c%e5%9b%9e%e6%bb%9a","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/20390\/","title":{"rendered":"\u5982\u4f55\u5229\u7528GitLab\u8fdb\u884c\u9879\u76ee\u7248\u672c\u53d1\u5e03\u548c\u56de\u6eda"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/000\/164\/169777551838633.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u5229\u7528GitLab\u8fdb\u884c\u9879\u76ee\u7248\u672c\u53d1\u5e03\u548c\u56de\u6eda\u63d2\u56fe\" alt=\"\u5982\u4f55\u5229\u7528GitLab\u8fdb\u884c\u9879\u76ee\u7248\u672c\u53d1\u5e03\u548c\u56de\u6eda\u63d2\u56fe\" \/><\/p>\n<p>\u5982\u4f55\u5229\u7528GitLab\u8fdb\u884c\u9879\u76ee\u7248\u672c\u53d1\u5e03\u548c\u56de\u6eda<\/p>\n<p>\u5f15\u8a00\uff1a<\/p>\n<p>\u5728\u8f6f\u4ef6\u5f00\u53d1\u8fc7\u7a0b\u4e2d\uff0c\u9879\u76ee\u7684\u7248\u672c\u53d1\u5e03\u548c\u56de\u6eda\u662f\u5f00\u53d1\u56e2\u961f\u5fc5\u4e0d\u53ef\u5c11\u7684\u4e00\u9879\u5de5\u4f5c\u3002GitLab\u662f\u4e00\u6b3e\u529f\u80fd\u5f3a\u5927\u7684\u7248\u672c\u63a7\u5236\u7cfb\u7edf\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u529f\u80fd\u548c\u5de5\u5177\u6765\u7ba1\u7406\u548c\u53d1\u5e03\u9879\u76ee\u7684\u4e0d\u540c\u7248\u672c\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u5229\u7528GitLab\u8fdb\u884c\u9879\u76ee\u7248\u672c\u53d1\u5e03\u548c\u56de\u6eda\uff0c\u5e76\u63d0\u4f9b\u5177\u4f53\u7684\u4ee3\u7801\u793a\u4f8b\u3002<\/p>\n<p>\u4e00\u3001\u9879\u76ee\u7248\u672c\u53d1\u5e03<\/p>\n<ol>\n<li>\u521b\u5efa\u65b0\u5206\u652f<br \/>\u5728GitLab\u4e0a\uff0c\u6bcf\u4e2a\u9879\u76ee\u90fd\u6709\u4e00\u4e2a\u4e3b\u5206\u652f\uff08\u4e00\u822c\u662fmaster\u6216main\uff09\u3002\u5f53\u9700\u8981\u53d1\u5e03\u65b0\u7684\u7248\u672c\u65f6\uff0c\u6211\u4eec\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5206\u652f\u6765\u8fdb\u884c\u5f00\u53d1\u548c\u6d4b\u8bd5\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5728\u672c\u5730\u521b\u5efa\u4e00\u4e2a\u65b0\u5206\u652f\uff0c\u5e76\u5c06\u5176\u63a8\u9001\u5230GitLab\u4e0a\uff1a<\/li>\n<\/ol>\n<pre>$ git checkout -b new_branch\n$ git push origin new_branch<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<ol>\n<li>\u5f00\u53d1\u548c\u6d4b\u8bd5<br \/>\u5728\u65b0\u5206\u652f\u4e0a\u8fdb\u884c\u5f00\u53d1\u548c\u6d4b\u8bd5\uff0c\u786e\u4fdd\u9879\u76ee\u7684\u65b0\u529f\u80fd\u6216\u4fee\u590d\u7684bug\u6ca1\u6709\u95ee\u9898\uff0c\u5e76\u901a\u8fc7\u5404\u79cd\u6d4b\u8bd5\u65b9\u6cd5\u8fdb\u884c\u9a8c\u8bc1\u3002\u5728\u8fd9\u4e2a\u9636\u6bb5\uff0c\u53ef\u4ee5\u591a\u6b21\u63d0\u4ea4\u4ee3\u7801\u5230GitLab\uff0c\u5e76\u901a\u8fc7Merge Request\u8bf7\u6c42\u5408\u5e76\u5230\u4e3b\u5206\u652f\u4e2d\u3002\u5728GitLab\u7684Merge Request\u9875\u9762\u4e2d\uff0c\u53ef\u4ee5\u67e5\u770b\u548c\u5ba1\u67e5\u5176\u4ed6\u4eba\u7684\u4ee3\u7801\u53d8\u66f4\u3002<\/li>\n<li>\u5ba1\u67e5\u548c\u5408\u5e76\u5206\u652f<br \/>\u5f53\u6240\u6709\u7684\u5f00\u53d1\u548c\u6d4b\u8bd5\u90fd\u5b8c\u6210\u540e\uff0c\u9700\u8981\u8fdb\u884c\u4ee3\u7801\u5ba1\u67e5\u3002\u53ef\u4ee5\u5b89\u6392\u9879\u76ee\u7ec4\u7684\u6210\u5458\u5bf9\u65b0\u5206\u652f\u7684\u4ee3\u7801\u8fdb\u884c\u5ba1\u67e5\u548c\u8bc4\u4f30\u3002\u5728GitLab\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7Merge Request\u6765\u5b8c\u6210\u4ee3\u7801\u7684\u5408\u5e76\u3002\u4f7f\u7528Merge Request\u53ef\u4ee5\u65b9\u4fbf\u5730\u67e5\u770b\u548c\u6bd4\u8f83\u4ee3\u7801\u53d8\u66f4\uff0c\u5e76\u8fdb\u884c\u7ebf\u4e0a\u8bc4\u5ba1\u548c\u8bc4\u8bba\u3002<\/li>\n<li>\u7248\u672c\u53d1\u5e03<br \/>\u5f53\u4ee3\u7801\u5ba1\u67e5\u901a\u8fc7\u540e\uff0c\u53ef\u4ee5\u5c06\u65b0\u5206\u652f\u5408\u5e76\u5230\u4e3b\u5206\u652f\u4e2d\uff0c\u5e76\u53d1\u5e03\u65b0\u7684\u7248\u672c\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5c06\u65b0\u5206\u652f\u5408\u5e76\u5230\u4e3b\u5206\u652f\u4e2d\uff1a<\/li>\n<\/ol>\n<pre>$ git checkout main\n$ git merge --no-ff new_branch\n$ git push origin main<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4e8c\u3001\u9879\u76ee\u7248\u672c\u56de\u6eda<\/p>\n<ol>\n<li>\u67e5\u770b\u63d0\u4ea4\u5386\u53f2<br \/>\u5728GitLab\u4e0a\uff0c\u53ef\u4ee5\u901a\u8fc7\u63d0\u4ea4\u5386\u53f2\u6765\u67e5\u770b\u9879\u76ee\u7684\u7248\u672c\u53d8\u66f4\u8bb0\u5f55\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u67e5\u770b\u5206\u652f\u7684\u63d0\u4ea4\u5386\u53f2\uff1a<\/li>\n<\/ol>\n<pre>$ git log<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<ol>\n<li>\u56de\u6eda\u5230\u67d0\u4e2a\u63d0\u4ea4<br \/>\u5f53\u9700\u8981\u56de\u6eda\u5230\u67d0\u4e2a\u7279\u5b9a\u7684\u7248\u672c\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5c06\u5206\u652f\u56de\u6eda\u5230\u6307\u5b9a\u7684\u63d0\u4ea4\uff1a<\/li>\n<\/ol>\n<pre>$ git revert &lt;commit_id&gt;\n$ git push origin main&lt;\/commit_id&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5176\u4e2d\uff0c  \u662f\u8981\u56de\u6eda\u7684\u63d0\u4ea4\u7684ID\u3002 <\/p>\n<ol>\n<li>\u521b\u5efa\u65b0\u7248\u672c<br \/>\u5f53\u56de\u6eda\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u5c06\u5206\u652f\u5408\u5e76\u5230\u4e3b\u5206\u652f\u4e2d\uff0c\u5e76\u53d1\u5e03\u65b0\u7684\u7248\u672c\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5c06\u56de\u6eda\u540e\u7684\u5206\u652f\u5408\u5e76\u5230\u4e3b\u5206\u652f\u4e2d\uff1a<\/li>\n<\/ol>\n<pre>$ git checkout main\n$ git merge --no-ff rolled_back_branch\n$ git push origin main<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5176\u4e2d\uff0crolled_back_branch\u662f\u56de\u6eda\u540e\u7684\u5206\u652f\u7684\u540d\u79f0\u3002<\/p>\n<p>\u7ed3\u8bba\uff1a<\/p>\n<p>GitLab\u662f\u4e00\u4e2a\u529f\u80fd\u5f3a\u5927\u7684\u7248\u672c\u63a7\u5236\u7cfb\u7edf\uff0c\u901a\u8fc7\u4f7f\u7528GitLab\uff0c\u6211\u4eec\u53ef\u4ee5\u65b9\u4fbf\u5730\u8fdb\u884c\u9879\u76ee\u7684\u7248\u672c\u53d1\u5e03\u548c\u56de\u6eda\u3002\u5728\u53d1\u5e03\u7248\u672c\u65f6\uff0c\u9700\u8981\u521b\u5efa\u65b0\u7684\u5206\u652f\u3001\u8fdb\u884c\u5f00\u53d1\u548c\u6d4b\u8bd5\u3001\u5ba1\u67e5\u548c\u5408\u5e76\u5206\u652f\uff0c\u5e76\u6700\u7ec8\u5408\u5e76\u5230\u4e3b\u5206\u652f\u4e2d\u3002\u5728\u56de\u6eda\u7248\u672c\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u67e5\u770b\u63d0\u4ea4\u5386\u53f2\u3001\u56de\u6eda\u5230\u6307\u5b9a\u7684\u63d0\u4ea4\uff0c\u5e76\u5c06\u56de\u6eda\u540e\u7684\u4ee3\u7801\u5408\u5e76\u5230\u4e3b\u5206\u652f\u4e2d\u3002\u901a\u8fc7\u5408\u7406\u4f7f\u7528GitLab\u7684\u529f\u80fd\u548c\u5de5\u5177\uff0c\u53ef\u4ee5\u63d0\u9ad8\u9879\u76ee\u5f00\u53d1\u548c\u7ba1\u7406\u7684\u6548\u7387\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u5229\u7528GitLab\u8fdb\u884c\u9879\u76ee\u7248\u672c\u53d1\u5e03\u548c\u56de\u6eda\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u5229\u7528GitLab\u8fdb\u884c\u9879\u76ee\u7248\u672c\u53d1\u5e03\u548c\u56de\u6eda \u5f15\u8a00\uff1a \u5728\u8f6f\u4ef6\u5f00\u53d1\u8fc7\u7a0b\u4e2d\uff0c\u9879\u76ee\u7684\u7248\u672c\u53d1\u5e03\u548c\u56de\u6eda\u662f\u5f00\u53d1\u56e2\u961f\u5fc5\u4e0d\u53ef\u5c11\u7684\u4e00\u9879\u5de5\u4f5c\u3002GitLab\u662f\u4e00\u6b3e\u529f\u80fd\u5f3a\u5927\u7684\u7248\u672c\u63a7\u5236\u7cfb\u7edf\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u529f\u80fd\u548c\u5de5\u5177\u6765\u7ba1\u7406\u548c\u53d1\u5e03\u9879\u76ee\u7684\u4e0d\u540c\u7248\u672c\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u5229\u7528GitLab\u8fdb\u884c\u9879\u76ee\u7248\u672c\u53d1\u5e03\u548c\u56de\u6eda\uff0c\u5e76\u63d0\u4f9b\u5177\u4f53\u7684\u4ee3\u7801\u793a\u4f8b\u3002 \u4e00\u3001\u9879\u76ee\u7248\u672c\u53d1\u5e03 \u521b\u5efa\u65b0\u5206\u652f\u5728GitLab\u4e0a\uff0c\u6bcf\u4e2a\u9879\u76ee\u90fd\u6709\u4e00\u4e2a\u4e3b\u5206\u652f\uff08\u4e00\u822c\u662fmaster\u6216main\uff09\u3002\u5f53\u9700\u8981\u53d1\u5e03\u65b0\u7684\u7248\u672c\u65f6\uff0c\u6211\u4eec\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5206\u652f\u6765\u8fdb\u884c\u5f00\u53d1\u548c\u6d4b\u8bd5\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5728\u672c\u5730\u521b\u5efa\u4e00\u4e2a\u65b0\u5206\u652f\uff0c\u5e76\u5c06\u5176\u63a8\u9001\u5230GitLab\u4e0a\uff1a $ git checkout -b new_branch $ git push origin new_branch \u767b\u5f55\u540e\u590d\u5236 \u5f00\u53d1\u548c\u6d4b\u8bd5\u5728\u65b0\u5206\u652f\u4e0a\u8fdb\u884c\u5f00\u53d1\u548c\u6d4b\u8bd5\uff0c\u786e\u4fdd\u9879\u76ee\u7684\u65b0\u529f\u80fd\u6216\u4fee\u590d\u7684bug\u6ca1\u6709\u95ee\u9898\uff0c\u5e76\u901a\u8fc7\u5404\u79cd\u6d4b\u8bd5\u65b9\u6cd5\u8fdb\u884c\u9a8c\u8bc1\u3002\u5728\u8fd9\u4e2a\u9636\u6bb5\uff0c\u53ef\u4ee5\u591a\u6b21\u63d0\u4ea4\u4ee3\u7801\u5230GitLab\uff0c\u5e76\u901a\u8fc7Merge Request\u8bf7\u6c42\u5408\u5e76\u5230\u4e3b\u5206\u652f\u4e2d\u3002\u5728GitLab\u7684Merge Request\u9875\u9762\u4e2d\uff0c\u53ef\u4ee5\u67e5\u770b\u548c\u5ba1\u67e5\u5176\u4ed6\u4eba\u7684\u4ee3\u7801\u53d8\u66f4\u3002 \u5ba1\u67e5\u548c\u5408\u5e76\u5206\u652f\u5f53\u6240\u6709\u7684\u5f00\u53d1\u548c\u6d4b\u8bd5\u90fd\u5b8c\u6210\u540e\uff0c\u9700\u8981\u8fdb\u884c\u4ee3\u7801\u5ba1\u67e5\u3002\u53ef\u4ee5\u5b89\u6392\u9879\u76ee\u7ec4\u7684\u6210\u5458\u5bf9\u65b0\u5206\u652f\u7684\u4ee3\u7801\u8fdb\u884c\u5ba1\u67e5\u548c\u8bc4\u4f30\u3002\u5728GitLab\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7Merge Request\u6765\u5b8c\u6210\u4ee3\u7801\u7684\u5408\u5e76\u3002\u4f7f\u7528Merge Request\u53ef\u4ee5\u65b9\u4fbf\u5730\u67e5\u770b\u548c\u6bd4\u8f83\u4ee3\u7801\u53d8\u66f4\uff0c\u5e76\u8fdb\u884c\u7ebf\u4e0a\u8bc4\u5ba1\u548c\u8bc4\u8bba\u3002 \u7248\u672c\u53d1\u5e03\u5f53\u4ee3\u7801\u5ba1\u67e5\u901a\u8fc7\u540e\uff0c\u53ef\u4ee5\u5c06\u65b0\u5206\u652f\u5408\u5e76\u5230\u4e3b\u5206\u652f\u4e2d\uff0c\u5e76\u53d1\u5e03\u65b0\u7684\u7248\u672c\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5c06\u65b0\u5206\u652f\u5408\u5e76\u5230\u4e3b\u5206\u652f\u4e2d\uff1a $ git checkout main $ git merge &#8211;no-ff new_branch $ git push origin main \u767b\u5f55\u540e\u590d\u5236 \u4e8c\u3001\u9879\u76ee\u7248\u672c\u56de\u6eda \u67e5\u770b\u63d0\u4ea4\u5386\u53f2\u5728GitLab\u4e0a\uff0c\u53ef\u4ee5\u901a\u8fc7\u63d0\u4ea4\u5386\u53f2\u6765\u67e5\u770b\u9879\u76ee\u7684\u7248\u672c\u53d8\u66f4\u8bb0\u5f55\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u67e5\u770b\u5206\u652f\u7684\u63d0\u4ea4\u5386\u53f2\uff1a $ git log \u767b\u5f55\u540e\u590d\u5236 \u56de\u6eda\u5230\u67d0\u4e2a\u63d0\u4ea4\u5f53\u9700\u8981\u56de\u6eda\u5230\u67d0\u4e2a\u7279\u5b9a\u7684\u7248\u672c\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5c06\u5206\u652f\u56de\u6eda\u5230\u6307\u5b9a\u7684\u63d0\u4ea4\uff1a $ git revert &lt;commit_id&gt; $ git push origin main&lt;\/commit_id&gt; \u767b\u5f55\u540e\u590d\u5236 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-20390","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/20390","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=20390"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/20390\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=20390"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=20390"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=20390"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}