{"id":10008281,"date":"2023-09-19T09:10:24","date_gmt":"2023-09-19T01:10:24","guid":{"rendered":"https:\/\/blog.itmax.cn\/?p=10008281"},"modified":"2023-09-19T09:10:24","modified_gmt":"2023-09-19T01:10:24","slug":"github%e7%9a%84%e4%b8%80%e4%b8%aa%e5%a5%87%e6%8a%80%e6%b7%ab%e5%b7%a7","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10008281","title":{"rendered":"Github\u7684\u4e00\u4e2a\u5947\u6280\u6deb\u5de7"},"content":{"rendered":"<h2>\u80cc\u666f<\/h2>\n<p>\u524d\u6bb5\u65f6\u95f4\u7ed9 <code>VictoriaLogs<\/code> \u63d0\u4ea4\u4e86\u4e00\u4e2a PR\uff1a<br \/><a target=\"_blank\" href=\"https:\/\/link.segmentfault.com\/?enc=jNhNaXjJBJHtM2rUJEeMIw%3D%3D.P%2BlXh162KrHea97EvYngGeVwT89ISMvuydeL1oxRYslxM27ULRPdatuAMyKW9dJ4pTMjfIrN0svq9qgmjppvuA%3D%3D\" rel=\"noopener noreferrer\">https:\/\/github.com\/VictoriaMetrics\/VictoriaMetrics\/pull\/4934<\/a><\/p>\n<p>\u672c\u6765\u4e00\u5207\u90fd\u5f88\u987a\u5229\uff0c\u53ea\u7b49\u5408\u5e76\u4e86\uff0c\u4f46\u5728\u4e34\u95e8\u4e00\u811a\u7684\u65f6\u5019\u793e\u533a\u7ef4\u62a4\u4eba\u5458\u95ee\u6211\u53ef\u5426\u7ed9 <code>git<\/code> <code>commit<\/code> \u52a0\u4e0a\u7b7e\u540d\u3002<\/p>\n<blockquote><p>\u4e8e\u662f\u6211\u5c31\u9ed8\u9ed8\u7684\u8c03\u8bd5\u5230\u4e86\u51cc\u6668\u56db\u70b9\ud83d\ude2d<\/p><\/blockquote>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000044229909\" alt=\"image.png\" title=\"image.png\"><\/p>\n<p>\u4ee5\u524d\u6211\u4e5f\u6ca1\u600e\u4e48\u6ce8\u610f\u8fc7\u8fd9\u4e2a\u9009\u9879\uff0c\u7ecf\u8fc7 <code>Google<\/code> \u540e\u53d1\u73b0 <code>Idea<\/code> \u5728\u63d0\u4ea4\u7684\u65f6\u5019\u53ef\u4ee5\u81ea\u884c\u8bbe\u7f6e\u3002<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000044229910\" alt=\"image.png\" title=\"image.png\" loading=\"lazy\"><br \/>\u5f53\u6211\u52fe\u9009\u4e86\u8fd9\u4e2a\u63d0\u4ea4\u65b0\u7684\u4ee3\u7801\u540e\uff0c\u4f9d\u7136\u88ab\u544a\u77e5\u6ca1\u6709\u6b63\u786e\u7684\u7b7e\u540d\uff0c\u8fd9\u65f6\u6211\u624d\u53d1\u73b0\u7406\u89e3\u9519\u8bef\u4e86\u3002<\/p>\n<h2>\u4e3a GitHub \u7684\u63d0\u4ea4\u7b7e\u540d<\/h2>\n<p>\u7ed3\u5408\u8fd9\u4f4d\u793e\u533a\u5927\u4f6c\u7ed9\u7684\u6587\u6863\uff0c\u4ed6\u6240\u9700\u8981\u7684\u662f\u6bcf\u6b21\u63d0\u4ea4\u7684\u4ee3\u7801\u90fd\u662f\u6709\u7b7e\u540d\u7684\uff0c\u7c7b\u4f3c\u4e8e\u8fd9\u6837\uff1a<br \/><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000044229911\" alt=\"image.png\" title=\"image.png\" loading=\"lazy\"><\/p>\n<p>\u5982\u679c\u6211\u4eec\u60f3\u8981 <code>GitHub<\/code> \u73b0\u5b9e <code>Verified<\/code> \u8fd9\u4e2a\u6807\u7b7e\uff0c\u90a3\u5c31\u9700\u8981\u5bf9 <code>commit<\/code> \u6216\u8005\u662f\u6253\u7684 <code>tag<\/code> \u8fdb\u884c\u7b7e\u540d\u3002<\/p>\n<p>\u800c\u7b7e\u540d\u7684\u65b9\u5f0f\u6709\u4e09\u79cd\uff1a<code>GPG<\/code>, <code>SSH<\/code>, <code>S\/MIME<\/code>\uff0c\u8fd9\u91cc\u6211\u4ee5 GPG \u7b7e\u540d\u4e3a\u4f8b\uff0c\u6574\u4f53\u6d41\u7a0b\u5982\u4e0b\uff1a<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000044229912\" alt=\"image.png\" title=\"image.png\" loading=\"lazy\"><\/p>\n<p>\u5148\u5728<a target=\"_blank\" href=\"https:\/\/link.segmentfault.com\/?enc=sBjQdXz2sj5%2FfS0Tt7UmjQ%3D%3D.maytZOQzeBLqnlV%2BKkyNSmgXsg9uwJYcPzcZeHASnyM%3D\" rel=\"noopener noreferrer\">https:\/\/www.gnupg.org\/download\/<\/a>\u8fd9\u91cc\u4e0b\u8f7d\u5b89\u88c5 GPG \u7684\u547d\u4ee4\u884c\u7a0b\u5e8f\u3002<\/p>\n<pre><code class=\"shell\">gpg --full-generate-key<\/code><\/pre>\n<p>\u4f7f\u7528\u8fd9\u4e2a\u547d\u4ee4\u751f\u6210 key\uff0c\u4e4b\u540e\u4f1a\u6839\u636e\u63d0\u793a\u5f55\u5165\u4e00\u4e9b\u4fe1\u606f\uff0c\u5305\u542b\u4f60\u7684 ID \u548c\u90ae\u7bb1\uff0c\u5efa\u8bae\u90fd\u548c GitHub \u7684 ID \u90ae\u7bb1\u4fdd\u6301\u4e00\u81f4\u5373\u53ef\uff0c\u7136\u540e\u4e00\u8def\u56de\u8f66\u5b8c\u4e8b\u3002<\/p>\n<p>\u4e4b\u540e\u53ef\u4ee5\u4f7f\u7528\u8fd9\u4e2a\u547d\u4ee4\u67e5\u770b\u521a\u624d\u521b\u5efa\u7684 Key\uff1a<\/p>\n<pre><code class=\"shell\">gpg --list-secret-keys --keyid-format=long\n------------------------------------\nsec   4096R\/3AA5C34371567BD2 2016-03-10 [expires: 2017-03-10]\nuid                          Hubot &lt;hubot@example.com&gt;\nssb   4096R\/4BB6D45482678BE3 2016-03-10<\/code><\/pre>\n<p>\u6211\u4eec\u9700\u8981\u5c06 <code>3AA5C34371567BD2<\/code> \u8fd9\u4e2a Key \u7684 ID \u5b57\u7b26\u4e32\u590d\u5236\uff0c\u4e4b\u540e\u6267\u884c\uff1a<\/p>\n<pre><code class=\"shell\">gpg --armor --export 3AA5C34371567BD2\n# Prints the GPG key ID, in ASCII armor format<\/code><\/pre>\n<p>\u6b64\u65f6\u4f1a\u6253\u5370\u51fa\u516c\u94a5\uff0c\u6211\u4eec\u5c06<\/p>\n<pre><code>-----BEGIN PGP PUBLIC KEY BLOCK-----\n-----END PGP PUBLIC KEY BLOCK-----<\/code><\/pre>\n<p>\u8fd9\u4e9b\u6570\u636e\u590d\u5236\u5230 GitHub \u7684\u4e2a\u4eba\u8bbe\u7f6e\u9875\u9762\uff1a<br \/><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000044229913\" alt=\"image.png\" title=\"image.png\" loading=\"lazy\"><\/p>\n<p>\u6b64\u65f6\u8fd8\u6ca1\u5b8c\uff0c\u5982\u679c\u6211\u4eec\u76f4\u63a5\u63d0\u4ea4\u4ee3\u7801\u7684\u4e5f\u4e0d\u4f1a\u6709 <code>Verified<\/code> \u7684\u6807\u7b7e\u3002<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000044229914\" alt=\"image.png\" title=\"image.png\" loading=\"lazy\"><\/p>\n<p>\u6211\u4eec\u8fd8\u9700\u8981\u6253\u5f00 git \u7684 config \u8bbe\u7f6e\uff1a<\/p>\n<pre><code class=\"shell\">git config commit.gpgsign true\n\n# \u5168\u5c40\u6253\u5f00\ngit config --global commit.gpgsign true\ngit commit -S -m &quot;YOUR_COMMIT_MESSAGE&quot;\ngit push<\/code><\/pre>\n<p>\u8fd9\u6837\u63d0\u4ea4\u7684 Commit \u5c31\u4f1a\u6253\u4e0a\u9a8c\u8bc1\u7684\u6807\u7b7e\u4e86\u3002<br \/><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000044229915\" alt=\"image.png\" title=\"image.png\" loading=\"lazy\"><\/p>\n<blockquote><p>-S \u7684\u6548\u679c\u548c\u5728 idea \u4e2d\u9009\u4e2d Sign-off \u7684\u6548\u679c\u4e00\u6837\u3002<\/p><\/blockquote>\n<p>\u5b98\u65b9\u6587\u6863\u4e5f\u6709\u8be6\u7ec6\u7684\u6b65\u9aa4\uff1a<br \/><a target=\"_blank\" href=\"https:\/\/link.segmentfault.com\/?enc=TQXiJpWJrtCRCEhILXREBQ%3D%3D.nlDkvWpgR%2FiHcaAZ%2BHLc47VrW%2BMsjkYDP1ap26OHPFQpq11Qp5TqN6o%2FGIkyUZPR8OLH3eUBlu%2Fnb2rPWmrnYa10wgxgvWOLFXMcqMHmqiN1VbJBnCJkpT8TsNuo6x7r2Ba34FGzhizOmwXN%2B191kFVy9QW6uS9V1FUgYxtbkg8%3D\" rel=\"noopener noreferrer\">https:\/\/docs.github.com\/en\/authentication\/managing-commit-signature-verification\/about-commit-signature-verification<\/a><\/p>\n<h2>Squash \u5408\u5e76\u63d0\u4ea4<\/h2>\n<p>\u4e0d\u8fc7\u5728\u6211\u8fd9\u4e2a <code>PR<\/code> \u7684\u80cc\u666f\u4e0b\u8fd8\u6709\u4e00\u4e2a\u6b65\u9aa4\u6ca1\u6709\u5b8c\u6210\uff0c\u5c31\u662f\u6211\u4e4b\u524d\u63d0\u4ea4\u7684 <code>Commit<\/code> \u90fd\u6ca1\u8981\u9a8c\u8bc1\uff0c\u6211\u9700\u8981\u5c06\u4ed6\u4eec\u90fd\u5408\u5e76\u4e3a\u4e00\u4e2a\u9a8c\u8bc1\u7684 Commit \u7136\u540e\u5728\u5f3a\u5236\u63a8\u9001\u4e0a\u53bb\uff0c\u8fd9\u6837\u6574\u4e2a <code>git log<\/code> \u770b\u8d77\u6765\u624d\u8db3\u591f\u7b80\u6d01\u3002<\/p>\n<p>\u6700\u7ec8\u6548\u679c\u5982\u4e0b\uff0c\u53ea\u6709\u4e00\u4e2a Commit \u5b58\u5728\u3002<br \/><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000044229916\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u8fd9\u65f6\u5019\u5c31\u5f97\u9700\u8981 git rebase \u51fa\u9a6c\u4e86\u3002<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000044229917\" alt=\"image.png\" title=\"image.png\" loading=\"lazy\"><br \/>\u4ee5\u521a\u624d\u6d4b\u8bd5\u7684\u8fd9\u4e24\u4e2a\u63d0\u4ea4\u4e3a\u4f8b\uff0c\u6211\u9700\u8981\u5c06\u4ed6\u4eec\u5408\u5e76\u4e3a\u4e00\u4e2a\u63d0\u4ea4\u3002<\/p>\n<p>\u6211\u4eec\u5148\u4f7f\u7528\u8fd9\u4e2a\u547d\u4ee4\uff1a<\/p>\n<pre><code class=\"shell\">git rebase -i HEAD~N\ngit rebase -i HEAD~2<\/code><\/pre>\n<p>N \u5c31\u662f\u6211\u4eec\u9700\u8981\u5408\u5e76\u51e0\u4e2a\u63d0\u4ea4\uff0c\u5728\u6211\u8fd9\u91cc\u5c31\u662f 2.<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000044229918\" alt=\"image.png\" title=\"image.png\" loading=\"lazy\"><br \/>\u6211\u4eec\u9700\u8981\u5c06\u9664\u4e86\u7b2c\u4e00\u4e2a commit \u4e4b\u5916\u7684\u90fd\u4fee\u6539\u4e3a s\uff0c\u4e5f\u5c31\u662f\u4e0b\u9762\u6ce8\u91ca\u91cc\u7684 <code>squash<\/code> \u7684\u7b80\u5199\uff08\u538b\u7f29\u7684\u610f\u601d\uff09\u3002<\/p>\n<p>\u8fd9\u662f\u4e00\u4e2a vim \u7684\u4ea4\u4e92\u7f16\u8f91\u6a21\u5f0f\uff0c\u7f16\u8f91\u5b8c\u6210\u4e4b\u540e\u4fdd\u5b58\u9000\u51fa\u3002<\/p>\n<blockquote><p>\u4e0d\u4f1a\u8fd8\u6709\u7a0b\u5e8f\u5458\u4e0d\u77e5\u9053\u5982\u4f55\u4fdd\u5b58 vim \u9000\u51fa\u5427\ud83d\udc15\u3002<\/p><\/blockquote>\n<p>\u4fdd\u5b58\u540e\u53c8\u4f1a\u5f39\u51fa\u4e00\u4e2a\u7f16\u8f91\u9875\u9762\uff0c\u8ba9\u6211\u4eec\u586b\u5199\u8fd9\u6b21\u538b\u7f29\u4e4b\u540e\u7684\u63d0\u4ea4\u8bb0\u5f55\uff0c\u9ed8\u8ba4\u4f1a\u5e2e\u6211\u751f\u6210\u597d\uff0c\u5f53\u7136\u4f60\u4e5f\u53ef\u4ee5\u5168\u90e8\u5220\u6389\u540e\u91cd\u5199\u3002<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000044229919\" alt=\"image.png\" title=\"image.png\" loading=\"lazy\"><\/p>\n<p>\u6211\u8fd9\u91cc\u5c31\u76f4\u63a5\u4f7f\u7528\u5b83\u751f\u6210\u597d\u7684\u5c31\u53ef\u4ee5\u4e86\uff0c\u4f9d\u7136\u8fd8\u662f\u4fdd\u5b58\u9000\u51fa\u3002<\/p>\n<p>\u6700\u540e\u518d\u5f3a\u884c\u63a8\u9001\u5230\u6211\u6240\u5728\u7684\u5206\u652f\u5373\u53ef\uff1a<\/p>\n<pre><code class=\"shell\">git push origin test-rebase -f<\/code><\/pre>\n<p>\u5728\u8fd9\u4e2a\u5206\u652f\u7684\u63d0\u4ea4\u9875\u9762\u4e5f\u53ea\u4f1a\u770b\u5230\u521a\u624d\u5f3a\u884c\u63a8\u9001\u7684\u8bb0\u5f55\u4e86\uff0c\u521a\u624d\u7684\u4e24\u4e2a\u63d0\u4ea4\u5df2\u7ecf\u5408\u5e76\u4e3a\u8fd9\u4e00\u4e2a\u4e86\u3002<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000044229920\" alt=\"image.png\" title=\"image.png\" loading=\"lazy\"><\/p>\n<h2>\u603b\u7ed3<\/h2>\n<p>\u501f\u7740\u8fd9\u4e2a\u673a\u4f1a\u4e5f\u4e86\u89e3\u4e86 <code>rebase<\/code> \u7684\u9a9a\u64cd\u4f5c\u633a\u591a\u7684\uff0c\u4e0d\u8fc7\u6211\u5e73\u65f6\u7528\u7684\u6700\u591a\u7684\u8fd8\u662f <code>merge<\/code>\uff0c\u8fd9\u4e2a\u5012\u6ca1\u6709\u597d\u574f\u4e4b\u5206\uff0c\u53ea\u8981\u540c\u7ec4\u7684\u5f00\u53d1\u8005\u90fd\u8fbe\u6210\u4e00\u81f4\u5373\u53ef\u3002<\/p>\n<p><a href=\"https:\/\/segmentfault.com\/a\/1190000044229907\">https:\/\/segmentfault.com\/a\/1190000044229907<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u80cc\u666f \u524d\u6bb5\u65f6\u95f4\u7ed9 VictoriaLogs \u63d0\u4ea4\u4e86\u4e00\u4e2a PR\uff1ahttps:\/\/github.com\/Victo [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-10008281","post","type-post","status-publish","format-standard","hentry","category-share"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10008281","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10008281"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10008281\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10008281"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10008281"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10008281"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}