{"id":5345,"date":"2022-06-13T22:48:14","date_gmt":"2022-06-13T14:48:14","guid":{"rendered":"https:\/\/dmesg.app\/?p=5345"},"modified":"2022-06-13T22:48:14","modified_gmt":"2022-06-13T14:48:14","slug":"change-git-user","status":"publish","type":"post","link":"https:\/\/dmesg.app\/change-git-user.html","title":{"rendered":"\u5982\u4f55\u66f4\u6539git commit user\uff1f"},"content":{"rendered":"<p>\u4e54\u6cbb\u00b7\u5965\u5a01\u5c14\u6709\u8a00<\/p>\n<blockquote><p>\u5386\u53f2\u4e0d\u662f\u4e00\u9762\u955c\u5b50\uff0c\u800c\u662f\u9ed1\u677f\u4e0a\u7684\u8bb0\u53f7\uff0c\u53ef\u4ee5\u968f\u65f6\u64e6\u53bb\uff0c\u968f\u65f6\u586b\u8865\u3002\u66f4\u4e3a\u53ef\u6015\u7684\u662f\uff0c\u4e00\u65e6\u6d82\u6539\u4e86\uff0c\u4f60\u627e\u4e0d\u5230\u8bc1\u636e\u53bb\u8bc1\u660e\u8fd9\u662f\u7be1\u6539\u5386\u53f2\u7684\u884c\u4e3a\u3002<\/p><\/blockquote>\n<p>Git\u4f1a\u8ffd\u8e2a\u6bcf\u4e00\u6b21commit\u7684\u5386\u53f2\u8bb0\u5f55\uff0c\u5982\u679c\u4e4b\u524d\u4e0d\u5c0f\u5fc3\u914d\u7f6e\u9519\u4e86\u7528\u6237\u540d\uff0c\u90a3\u4e48\u6709\u529e\u6cd5\u6539\u6389\u5417\uff1f<\/p>\n<p>\u5f53\u7136\u4e86\u529e\u6cd5\u662f\u6709\u7684\uff0c\u6539\u6389commit username\u548cemail\u662f\u5f88\u5bb9\u6613\u7684\uff0c\u4e0d\u5c31\u662f\u8fd9\u4e48\u51e0\u884c\u561b\uff1f<\/p>\n<pre class=\"prettyprint linenums\">git rebase -i f25f719f7c2333d310696c3ed41e5a90ed078e55\r\n<\/pre>\n<p>\u5f39\u51fa\u7684\u4ea4\u4e92\u5f0f\u7a97\u53e3\uff0c\u628a\u8981\u6539\u7684commit\u4ece<code>pick<\/code>\u6539\u6210<code>edit<\/code><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1026\" height=\"266\" class=\"wp-image-5346\" src=\"https:\/\/7bc5d24.webp.ee\/wp-content\/uploads\/2022\/06\/2022061322415582.png\" alt=\"\u5982\u4f55\u66f4\u6539git commit user\uff1f\" title=\"\u5982\u4f55\u66f4\u6539git commit user\uff1f\" \/><\/p>\n<p>\u7136\u540e\u4e0d\u505c\u5730<\/p>\n<pre class=\"prettyprint linenums\">git commit --amend --author=&quot;Cool &lt;cool@gmail.com&gt;&quot; --no-edit &amp;&amp; git rebase --continue\r\n<\/pre>\n<p>\u5c31\u53ef\u4ee5\u4e86<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1402\" height=\"1458\" class=\"wp-image-5347\" src=\"https:\/\/7bc5d24.webp.ee\/wp-content\/uploads\/2022\/06\/2022061322415653.png\" alt=\"\u5982\u4f55\u66f4\u6539git commit user\uff1f\" title=\"\u5982\u4f55\u66f4\u6539git commit user\uff1f\" \/><\/p>\n<p>\u4e8b\u5b9e\u679c\u771f\u5982\u6b64\u5417\uff1f<code>git push -fv<\/code>\u8bd5\u8bd5\u770b\uff1f<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1504\" height=\"782\" class=\"wp-image-5348\" src=\"https:\/\/7bc5d24.webp.ee\/wp-content\/uploads\/2022\/06\/2022061322415838.png\" alt=\"\u5982\u4f55\u66f4\u6539git commit user\uff1f\" title=\"\u5982\u4f55\u66f4\u6539git commit user\uff1f\" \/><br \/>\n<a href=\"https:\/\/dmesg.app\/wp-content\/uploads\/2022\/06\/2022061322453057.jpg\" alt=\"\u5982\u4f55\u66f4\u6539git commit user\uff1f\" title=\"\u5982\u4f55\u66f4\u6539git commit user\uff1f\" rel=\"box\" class=\"fancybox\"><img loading=\"lazy\" decoding=\"async\" width=\"281\" height=\"179\" class=\"alignnone size-full wp-image-5351\" src=\"https:\/\/7bc5d24.webp.ee\/wp-content\/uploads\/2022\/06\/2022061322453057.jpg\" alt=\"\u5982\u4f55\u66f4\u6539git commit user\uff1f\" title=\"\u5982\u4f55\u66f4\u6539git commit user\uff1f\" alt=\"\" \/><\/a><\/p>\n<hr \/>\n<p>\u5988\u52d2\u4e2a\u5df4\u5b50\uff0c\u65f6\u95f4\u4e0d\u5bf9\u554a\uff0c\u660e\u660e\u662fFeb\u7684\u600e\u4e48\u5c31\u53d8\u6210\u4e86\u73b0\u5728\u7684\u65f6\u95f4\u4e86\u3002\u8fd9\u4e0d\u5c31\u9732\u9985\u4e86\u5417\uff01<\/p>\n<p>\u5343\u8f9b\u4e07\u82e6\u627e\u5230\u4e00\u4e2a\u540d\u5b57\u53eb<a href=\"https:\/\/github.com\/newren\/git-filter-repo\">git-filter-repo<\/a>\u7684\u4e1c\u897f\uff0c\u8bd5\u4e86\u4e00\u4e0b\u662f\u53ef\u4ee5\u7684\u3002<\/p>\n<p>\u5148\u5b89\u88c5\uff0c\u6bd4\u5982\u8bf4 <code>apt install git-filter-repo<\/code><\/p>\n<p>\u7136\u540e\u521b\u5efa\u4e00\u4e2a<code>mailmap<\/code>\u6587\u4ef6\uff0c\u683c\u5f0f\u5982\u4e0b<\/p>\n<pre class=\"prettyprint linenums\">New &lt;new@gmail.com&gt; BennyThink &lt;benny.think@gmail.com&gt;\r\n<\/pre>\n<p>\u5982\u6709\u9700\u8981\u53ef\u4ee5\u5199\u591a\u884c<\/p>\n<p>\u7136\u540e<\/p>\n<pre class=\"prettyprint linenums\">git filter-repo --mailmap \/etc\/mailmap\r\n<\/pre>\n<p>\u7136\u540e\u518dpush\uff0c\u5982\u679c\u9047\u5230\u7f3a\u5931remote\u7684\u95ee\u9898\uff0c\u91cd\u65b0\u6dfb\u52a0\u4e00\u4e0b<\/p>\n<pre class=\"prettyprint linenums\">git remote add origin https:\/\/github.com\/tgbot-collection\/history\r\ngit push --set-upstream origin master -fv\r\n<\/pre>\n<p>\u4f18\u79c0\u5427\uff01\u5168\u53d8\u6210\u5bf9\u5e94\u7684\u540d\u5b57\u548c\u90ae\u7bb1\u4e86\uff0c\u5e76\u4e14commit\u7684\u65f6\u95f4\u4e5f\u6ca1\u6709\u6539\u53d8\u3002<code>git log<\/code>\u548cGitHub\u662f\u4e00\u81f4\u7684\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1450\" height=\"1026\" class=\"wp-image-5349\" src=\"https:\/\/7bc5d24.webp.ee\/wp-content\/uploads\/2022\/06\/2022061322420811.png\" alt=\"\u5982\u4f55\u66f4\u6539git commit user\uff1f\" title=\"\u5982\u4f55\u66f4\u6539git commit user\uff1f\" \/><\/p>\n<p>\u5982\u679c\u60f3\u8981\u53ea\u6539\u51e0\u4e2acommit\u7684\u90ae\u7bb1\uff0c\u90a3\u600e\u4e48\u529e\u5462\uff1f<\/p>\n<p>\u6bd4\u5982\u8bf4\u53ea\u60f3\u6539\u524d\u4e24\u4e2a<\/p>\n<pre class=\"prettyprint linenums\">git filter-repo --refs master~2..master --mailmap \/etc\/mailmap\r\n<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"2376\" height=\"1116\" class=\"wp-image-5350\" src=\"https:\/\/7bc5d24.webp.ee\/wp-content\/uploads\/2022\/06\/2022061322420927.png\" alt=\"\u5982\u4f55\u66f4\u6539git commit user\uff1f\" title=\"\u5982\u4f55\u66f4\u6539git commit user\uff1f\" \/><\/p>\n<p>\u5982\u679c\u60f3\u6539\u67d0\u4e2a\u4e2d\u95f4\u7684\u4e00\u4e9bcommit\u7684\u90ae\u7bb1\u4e3a\u67d0\u4e2a\u4eba\u3001\u5e76\u4e14\u8fd8\u4e0d\u6539\u53d8GitHub\u4e0a\u663e\u793a\u7684\u65f6\u95f4\u5462\uff1f\u751a\u81f3\u4e0d\u6562\u786e\u5b9a\u8fd9\u79cd\u662f\u5426\u53ef\u884c\ud83d\ude02<\/p>\n<p>emmm\u8fd9\u4e2a\u6211\u8fd8\u4e0d\u592a\u77e5\u9053\uff0c\u5176\u5b9e\u4e0d\u592a\u77e5\u9053refs\u662f\u4ec0\u4e48\u610f\u601d\uff0c\u5c1d\u8bd5\u4e86\u5f88\u4e45\u4e5f\u4e0d\u884c<\/p>\n<p>\u770b\u5230git-filter-repo\u91cc\u5199\u7740<\/p>\n<pre class=\"prettyprint linenums\">git filter-repo ... --refs C..H\r\ngit filter-repo ... --refs C..H ^D\r\ngit filter-repo ... --refs D..H ^C\r\n<\/pre>\n<p>H\u5e94\u8be5\u6307\u7684\u662fHEAD\uff1f<\/p>\n<p>\u603b\u4e4b\uff0c\u6682\u65f6\u591f\u7528\u4e86\ud83d\ude02<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e54\u6cbb\u00b7\u5965\u5a01\u5c14\u6709\u8a00 \u5386\u53f2\u4e0d\u662f\u4e00\u9762\u955c\u5b50\uff0c\u800c\u662f\u9ed1\u677f\u4e0a\u7684\u8bb0\u53f7\uff0c\u53ef\u4ee5\u968f\u65f6\u64e6\u53bb\uff0c\u968f\u65f6\u586b\u8865\u3002\u66f4\u4e3a\u53ef\u6015\u7684\u662f\uff0c\u4e00\u65e6\u6d82\u6539\u4e86\uff0c\u4f60\u627e\u4e0d [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[45],"tags":[],"class_list":["post-5345","post","type-post","status-publish","format-standard","hentry","category-what"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/dmesg.app\/wp-json\/wp\/v2\/posts\/5345","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dmesg.app\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dmesg.app\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dmesg.app\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dmesg.app\/wp-json\/wp\/v2\/comments?post=5345"}],"version-history":[{"count":3,"href":"https:\/\/dmesg.app\/wp-json\/wp\/v2\/posts\/5345\/revisions"}],"predecessor-version":[{"id":5354,"href":"https:\/\/dmesg.app\/wp-json\/wp\/v2\/posts\/5345\/revisions\/5354"}],"wp:attachment":[{"href":"https:\/\/dmesg.app\/wp-json\/wp\/v2\/media?parent=5345"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dmesg.app\/wp-json\/wp\/v2\/categories?post=5345"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dmesg.app\/wp-json\/wp\/v2\/tags?post=5345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}