{"id":5862,"date":"2022-01-14T14:48:17","date_gmt":"2022-01-14T06:48:17","guid":{"rendered":"http:\/\/xinyiworld.top\/wordpress\/?p=5862"},"modified":"2024-08-29T09:38:10","modified_gmt":"2024-08-29T01:38:10","slug":"git%e6%8c%87%e4%bb%a4%e5%a4%a7%e5%85%a8","status":"publish","type":"post","link":"http:\/\/xinyiworld.top\/wordpress_it\/?p=5862","title":{"rendered":"Git\u6307\u4ee4\u5927\u5168"},"content":{"rendered":"<p><a href=\"https:\/\/github.com\/github\/gitignore\/blob\/main\/Android.gitignore\">https:\/\/github.com\/github\/gitignore\/blob\/main\/Android.gitignore<\/a>\uff08gradle\u7684\u5b98\u65b9\u5ffd\u7565\u6587\u4ef6\uff09<br \/>\n<a href=\"https:\/\/www.yiibai.com\/git\/git_rm.html\">https:\/\/www.yiibai.com\/git\/git_rm.html<\/a><\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_16 counter-hierarchy counter-decimal ez-toc-grey\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\">\u76ee\u5f55<\/p>\n<span class=\"ez-toc-title-toggle\"><a class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" style=\"display: none;\"><i class=\"ez-toc-glyphicon ez-toc-icon-toggle\"><\/i><\/a><\/span><\/div>\n<nav><ul class=\"ez-toc-list ez-toc-list-level-1\"><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-1\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=5862\/#%E5%BF%BD%E7%95%A5\" title=\"\u5ffd\u7565\">\u5ffd\u7565<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-2\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=5862\/#%E9%85%8D%E7%BD%AE\" title=\"\u914d\u7f6e\">\u914d\u7f6e<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-3\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=5862\/#%E6%92%A4%E6%B6%88\" title=\"\u64a4\u6d88\">\u64a4\u6d88<\/a><ul class=\"ez-toc-list-level-4\"><li class=\"ez-toc-heading-level-4\"><a class=\"ez-toc-link ez-toc-heading-4\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=5862\/#%E5%9F%BA%E6%9C%AC%E6%8C%87%E4%BB%A4\" title=\"\u57fa\u672c\u6307\u4ee4\">\u57fa\u672c\u6307\u4ee4<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-4\"><a class=\"ez-toc-link ez-toc-heading-5\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=5862\/#%E9%87%8D%E7%BD%AE%E6%8F%AD%E5%AF%86\" title=\"\u91cd\u7f6e\u63ed\u5bc6\">\u91cd\u7f6e\u63ed\u5bc6<\/a><\/li><\/ul><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-6\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=5862\/#%E6%A3%80%E5%87%BA\" title=\"\u68c0\u51fa\">\u68c0\u51fa<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-7\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=5862\/#%E5%90%88%E5%B9%B6\" title=\"\u5408\u5e76\">\u5408\u5e76<\/a><ul class=\"ez-toc-list-level-4\"><li class=\"ez-toc-heading-level-4\"><a class=\"ez-toc-link ez-toc-heading-8\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=5862\/#%E5%8F%98%E5%9F%BA%EF%BC%88rebase%EF%BC%89\" title=\"\u53d8\u57fa\uff08rebase\uff09\">\u53d8\u57fa\uff08rebase\uff09<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-4\"><a class=\"ez-toc-link ez-toc-heading-9\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=5862\/#cherry-pick\" title=\"cherry-pick\">cherry-pick<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-4\"><a class=\"ez-toc-link ez-toc-heading-10\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=5862\/#merge\" title=\"merge\">merge<\/a><\/li><\/ul><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-11\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=5862\/#%E8%B4%AE%E8%97%8F%E4%B8%8E%E6%B8%85%E7%90%86\" title=\"\u8d2e\u85cf\u4e0e\u6e05\u7406\">\u8d2e\u85cf\u4e0e\u6e05\u7406<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-12\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=5862\/#%E6%9F%A5%E7%9C%8B%E5%8E%86%E5%8F%B2%E8%AE%B0%E5%BD%95\" title=\"\u67e5\u770b\u5386\u53f2\u8bb0\u5f55\">\u67e5\u770b\u5386\u53f2\u8bb0\u5f55<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-13\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=5862\/#%E9%87%8D%E5%91%BD%E5%90%8D%E5%88%86%E6%94%AF\" title=\"\u91cd\u547d\u540d\u5206\u652f\">\u91cd\u547d\u540d\u5206\u652f<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-14\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=5862\/#%E5%88%A0%E9%99%A4%E8%BF%9C%E7%A8%8B%E5%88%86%E6%94%AF\" title=\"\u5220\u9664\u8fdc\u7a0b\u5206\u652f\">\u5220\u9664\u8fdc\u7a0b\u5206\u652f<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-15\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=5862\/#%E6%96%B0%E5%BB%BA%E5%B9%B6%E5%88%87%E6%8D%A2%E5%88%86%E6%94%AF\" title=\"\u65b0\u5efa\u5e76\u5207\u6362\u5206\u652f\">\u65b0\u5efa\u5e76\u5207\u6362\u5206\u652f<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-16\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=5862\/#%E5%88%86%E6%94%AF%E5%AF%B9%E6%AF%94%E5%91%BD%E4%BB%A4\" title=\"\u5206\u652f\u5bf9\u6bd4\u547d\u4ee4\">\u5206\u652f\u5bf9\u6bd4\u547d\u4ee4<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-17\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=5862\/#%E5%88%A0%E9%99%A4%E6%89%80%E6%9C%89_Commit_%E6%8F%90%E4%BA%A4%E8%AE%B0%E5%BD%95\" title=\"\u5220\u9664\u6240\u6709 Commit \u63d0\u4ea4\u8bb0\u5f55\">\u5220\u9664\u6240\u6709 Commit \u63d0\u4ea4\u8bb0\u5f55<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-18\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=5862\/#%E6%A0%87%E7%AD%BE%E6%93%8D%E4%BD%9C\" title=\"\u6807\u7b7e\u64cd\u4f5c\">\u6807\u7b7e\u64cd\u4f5c<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-19\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=5862\/#%E6%9B%B4%E6%8D%A2%E8%BF%9C%E7%A8%8B%E5%9C%B0%E5%9D%80\" title=\"\u66f4\u6362\u8fdc\u7a0b\u5730\u5740\">\u66f4\u6362\u8fdc\u7a0b\u5730\u5740<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-20\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=5862\/#%E4%BF%AE%E6%94%B9%E8%BF%9C%E7%A8%8B%E5%88%86%E6%94%AF%E5%90%8D%E7%A7%B0\" title=\"\u4fee\u6539\u8fdc\u7a0b\u5206\u652f\u540d\u79f0\">\u4fee\u6539\u8fdc\u7a0b\u5206\u652f\u540d\u79f0<\/a><\/li><\/ul><\/nav><\/div>\n<h3><span class=\"ez-toc-section\" id=\"%E5%BF%BD%E7%95%A5\"><\/span>\u5ffd\u7565<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li>git \u6ca1\u6709\u52a0\u5165\u5230.gitignore\u7684\u6587\u4ef6\u63d0\u4ea4\u4e86,\u5982\u4f55\u5ffd\u7565\n<pre><code class=\"language-bash\">echo &quot;your_file_name&quot; &gt;&gt; .gitignore  # \u5c06\u6587\u4ef6\u540d\u6dfb\u52a0\u5230.gitignore\u4e2d\ngit rm --cached your_file_name      # \u4eceGit\u8ddf\u8e2a\u4e2d\u79fb\u9664\u6587\u4ef6\uff0c\u4f46\u4fdd\u7559\u5728\u672c\u5730\ngit commit -m &quot;Remove file from tracking&quot;  # \u63d0\u4ea4\u66f4\u6539<\/code><\/pre>\n<\/li>\n<\/ul>\n<p>your_file_name\u4e00\u822c\u7528\u901a\u914d\u5199\u6cd5<\/p>\n<h3><span class=\"ez-toc-section\" id=\"%E9%85%8D%E7%BD%AE\"><\/span>\u914d\u7f6e<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><a href=\"https:\/\/blog.csdn.net\/qq_29232943\/article\/details\/103121667\">https:\/\/blog.csdn.net\/qq_29232943\/article\/details\/103121667<\/a><\/p>\n<p>\u4e0d\u4f7f\u7528ssh\u516c\u94a5\uff0c\u907f\u514d\u6bcf\u6b21push\u90fd\u8981\u8f93\u5165\u5bc6\u7801:<br \/>\n<code>git config --global credential.helper store<\/code><\/p>\n<p>\u6062\u590d\u9ed8\u8ba4\u503c\uff1a<br \/>\n<code>git config [--global] --unset key<\/code><\/p>\n<p>\u8bb0\u4f4f\u5bc6\u7801\uff1a<br \/>\n<code>git config --global credential.helper store<\/code><\/p>\n<h3><span class=\"ez-toc-section\" id=\"%E6%92%A4%E6%B6%88\"><\/span>\u64a4\u6d88<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><a href=\"https:\/\/git-scm.com\/book\/zh\/v2\/Git-%E5%9F%BA%E7%A1%80-%E6%92%A4%E6%B6%88%E6%93%8D%E4%BD%9C\">https:\/\/git-scm.com\/book\/zh\/v2\/Git-%E5%9F%BA%E7%A1%80-%E6%92%A4%E6%B6%88%E6%93%8D%E4%BD%9C<\/a><\/p>\n<p><a href=\"https:\/\/www.jianshu.com\/p\/c0f7e4ac14c7\">https:\/\/www.jianshu.com\/p\/c0f7e4ac14c7<\/a><\/p>\n<h4><span class=\"ez-toc-section\" id=\"%E5%9F%BA%E6%9C%AC%E6%8C%87%E4%BB%A4\"><\/span>\u57fa\u672c\u6307\u4ee4<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<ul>\n<li>\u4fee\u8865\u67d0\u6b21commit<br \/>\n\u67d0\u6b21commit\u7684\u4fe1\u606f\u60f3\u4fee\u6539\uff0c\u67d0\u6b21commit\u5fd8\u4e86add\u67d0\u4e2a\u6587\u4ef6\uff0c\u4f46\u662f\u53c8\u4e0d\u60f3\u91cd\u65b0\u751f\u6210\u65b0\u7684commit\uff0c\u53ef\u4ee5\u6267\u884c\uff1a<br \/>\n<code>git commit --amend<\/code><br \/>\n<img src=\"http:\/\/xinyiworld.top\/wordpress\/wp-content\/uploads\/2022\/01\/5E16CE47-9534-4332-8B9A-EA218015CD78.png\" alt=\"\" \/><\/li>\n<\/ul>\n<p>\u901a\u8fc7vim\u7f16\u8f91\u4fee\u6539commit\u7684\u4fe1\u606f\u4fdd\u5b58\u540e\uff0c\u901a\u8fc7git log\u53ef\u4ee5\u8fdb\u884c\u9a8c\u8bc1\u3002<\/p>\n<p>\u5982\u5b98\u65b9\u6587\u6863\u6240\u8a00:<\/p>\n<blockquote>\n<p>\u5f53\u4f60\u5728\u4fee\u8865\u6700\u540e\u7684\u63d0\u4ea4\u65f6\uff0c\u4e0e\u5176\u8bf4\u662f\u4fee\u590d\u65e7\u63d0\u4ea4\uff0c\u5012\u4e0d\u5982\u8bf4\u662f\u5b8c\u5168\u7528\u4e00\u4e2a \u65b0\u7684\u63d0\u4ea4 \u66ff\u6362\u65e7\u7684\u63d0\u4ea4\uff0c \u7406\u89e3\u8fd9\u4e00\u70b9\u975e\u5e38\u91cd\u8981\u3002\u4ece\u6548\u679c\u4e0a\u6765\u8bf4\uff0c\u5c31\u50cf\u662f\u65e7\u6709\u7684\u63d0\u4ea4\u4ece\u672a\u5b58\u5728\u8fc7\u4e00\u6837\uff0c\u5b83\u5e76\u4e0d\u4f1a\u51fa\u73b0\u5728\u4ed3\u5e93\u7684\u5386\u53f2\u4e2d\u3002<\/p>\n<p>\u4fee\u8865\u63d0\u4ea4\u6700\u660e\u663e\u7684\u4ef7\u503c\u662f\u53ef\u4ee5\u7a0d\u5fae\u6539\u8fdb\u4f60\u6700\u540e\u7684\u63d0\u4ea4\uff0c\u800c\u4e0d\u4f1a\u8ba9\u201c\u554a\uff0c\u5fd8\u4e86\u6dfb\u52a0\u4e00\u4e2a\u6587\u4ef6\u201d\u6216\u8005 \u201c\u5c0f\u4fee\u8865\uff0c\u4fee\u6b63\u7b14\u8bef\u201d\u8fd9\u79cd\u63d0\u4ea4\u4fe1\u606f\u5f04\u4e71\u4f60\u7684\u4ed3\u5e93\u5386\u53f2\u3002<\/p>\n<\/blockquote>\n<p>\u4fee\u6539commit\u7684author\u4fe1\u606f\uff1a<a href=\"https:\/\/www.cnblogs.com\/yanglang\/p\/11794861.html\">https:\/\/www.cnblogs.com\/yanglang\/p\/11794861.html<\/a><\/p>\n<ul>\n<li>\u64a4\u6d88add<br \/>\n<strong>\u65b9\u6cd51\uff1a<\/strong><\/li>\n<\/ul>\n<p>\u5c31\u662f\u5c06\u6587\u4ef6\u4ece\u6682\u5b58\u533a\u79fb\u9664\u81f3\u5de5\u4f5c\u533a<br \/>\n<code>git reset HEAD &lt;file&gt;<\/code>  \uff1a\u79fb\u9664\u67d0\u4e2a\u6587\u4ef6.<\/p>\n<p><code>git reset HEAD<\/code> :\u79fb\u9664\u6240\u6709\u6587\u4ef6<\/p>\n<p><strong>\u65b9\u6cd52\uff1a<\/strong><br \/>\n<img src=\"http:\/\/xinyiworld.top\/wordpress_it\/wp-content\/uploads\/2022\/01\/git-reset-add.png\" alt=\"\" \/><\/p>\n<ul>\n<li>\u64a4\u6d88\u5bf9\u6587\u4ef6\u7684\u4fee\u6539<br \/>\n<code>git checkout -- &lt;file&gt;<\/code>\uff1afile\u53ef\u4ee5\u662f.\uff08\u5168\u90e8\u6587\u4ef6\uff09\uff0c<em>\/\u6587\u4ef6\u5939\/<\/em>(\u67d0\u4e2a\u6587\u4ef6\u4e0b\u7684\u6240\u6709\u6587\u4ef6)<br \/>\n<a href=\"https:\/\/www.jianshu.com\/p\/285302d1eb73\">https:\/\/www.jianshu.com\/p\/285302d1eb73<\/a>(\u8be6\u89e3)<\/li>\n<\/ul>\n<p>\u8fd9\u4e2a\u6307\u4ee4\u7684\u771f\u6b63\u542b\u4e49\uff1a<br \/>\n<img src=\"http:\/\/xinyiworld.top\/wordpress\/wp-content\/uploads\/2022\/01\/C73042AC-6023-4589-8178-FFDDEA76F04B.png\" alt=\"\" \/><\/p>\n<p>\u5b98\u65b9Note:<\/p>\n<blockquote>\n<p>\u8bf7\u52a1\u5fc5\u8bb0\u5f97 <code>git checkout -- &lt;file&gt;<\/code> \u662f\u4e00\u4e2a\u5371\u9669\u7684\u547d\u4ee4\u3002 \u4f60\u5bf9\u90a3\u4e2a\u6587\u4ef6\u5728\u672c\u5730\u7684\u4efb\u4f55\u4fee\u6539\u90fd\u4f1a\u6d88\u5931\u2014\u2014Git \u4f1a\u7528\u6700\u8fd1\u63d0\u4ea4\u7684\u7248\u672c\u8986\u76d6\u6389\u5b83\u3002 \u9664\u975e\u4f60\u786e\u5b9e\u6e05\u695a\u4e0d\u60f3\u8981\u5bf9\u90a3\u4e2a\u6587\u4ef6\u7684\u672c\u5730\u4fee\u6539\u4e86\uff0c\u5426\u5219\u8bf7\u4e0d\u8981\u4f7f\u7528\u8fd9\u4e2a\u547d\u4ee4\u3002<\/p>\n<\/blockquote>\n<ul>\n<li>\n<p>\u6700\u65b0\u521b\u5efa\u7684\u4f46\u662f\u8fd8\u6ca1\u6709add\u7684\u6587\u4ef6\u5982\u4f55\u5220\u9664<br \/>\n<a href=\"https:\/\/blog.csdn.net\/weixin_39607620\/article\/details\/111490527\">https:\/\/blog.csdn.net\/weixin_39607620\/article\/details\/111490527<\/a><br \/>\n\u901a\u8fc7<code>git clean<\/code>\u6307\u4ee4<\/p>\n<\/li>\n<li>\n<p>\u64a4\u9500\u67d0\u6b21commit\u7684\u6587\u4ef6<\/p>\n<\/li>\n<\/ul>\n<p><a href=\"https:\/\/blog.csdn.net\/qq_20817327\/article\/details\/124823178\">https:\/\/blog.csdn.net\/qq_20817327\/article\/details\/124823178<\/a><br \/>\n\u89e3\u51b3\u8fc7\u7a0b<br \/>\n\u9996\u5148\u67e5\u8be2\u8fd9\u4e2a\u6587\u4ef6\u7684log<\/p>\n<p><code>$ git log &lt;fileName&gt;<\/code><\/p>\n<p>\u5176\u6b21\u67e5\u627e\u5230\u8fd9\u4e2a\u6587\u4ef6\u7684\u4e0a\u6b21commit id xxx\uff08\u8981\u6062\u590d\u5230\u7684\u90a3\u4e2a\u6b63\u786e\u7684commit\uff09\uff0c<strong>\u6ce8\u610fcommit-id\u8981\u5199\u5168<\/strong>\uff0c\u5e76\u5bf9\u5176\u8fdb\u884creset\u64cd\u4f5c\u3002<\/p>\n<p><code>$ git reset &lt;commit-id&gt; &lt;fileName&gt;<\/code><\/p>\n<p>\u518d\u64a4\u9500\u5bf9\u6b64\u6587\u4ef6\u7684\u4fee\u6539<\/p>\n<p><code>$ git checkout &lt;fileName&gt;<\/code><\/p>\n<p>\u6700\u540eamend\u4e00\u4e0b\uff0c\u518dpush\u4e0a\u53bb<\/p>\n<pre><code class=\"language-bash\">$ git commit --amend\n$ git push origin &lt;remoteBranch&gt;<\/code><\/pre>\n<h4><span class=\"ez-toc-section\" id=\"%E9%87%8D%E7%BD%AE%E6%8F%AD%E5%AF%86\"><\/span>\u91cd\u7f6e\u63ed\u5bc6<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p><a href=\"https:\/\/git-scm.com\/book\/zh\/v2\/Git-%E5%B7%A5%E5%85%B7-%E9%87%8D%E7%BD%AE%E6%8F%AD%E5%AF%86#_git_reset\">https:\/\/git-scm.com\/book\/zh\/v2\/Git-%E5%B7%A5%E5%85%B7-%E9%87%8D%E7%BD%AE%E6%8F%AD%E5%AF%86#_git_reset<\/a><\/p>\n<p><code>git reset --soft\/mixed\/hard<\/code>\uff1a\u7406\u89e3\u4e09\u4e2a\u53c2\u6570\u7684\u533a\u522b<\/p>\n<p><img src=\"http:\/\/xinyiworld.top\/wordpress_it\/wp-content\/uploads\/2022\/01\/CA8EBCC4-7FB2-49ff-BAE7-FC682EFB6A25.png\" alt=\"\" \/><\/p>\n<pre><code class=\"language-bash\">--mixed \u662f\u9ed8\u8ba4\u7684\u9009\u9879\nGit reset\u4f1a\u9000\u56de\u5230\u67d0\u4e2acommit \u7136\u540e\u6587\u4ef6\u4e5funtracked\u4e86\ngit reset --soft \u9000\u56de\u5230\u67d0\u4e2acommit \u7136\u540e\u6587\u4ef6\u5df2\u7ecf\u88abadd\u4e86<\/code><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"%E6%A3%80%E5%87%BA\"><\/span>\u68c0\u51fa<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><code>git checkout<\/code>\uff0c\u4e0d\u5149\u53ef\u4ee5\u5207\u6362\u5206\u652f\uff0c\u4e5f\u53ef\u4ee5\u68c0\u51fa\u5177\u4f53\u7684commit-id\uff0ctag\uff0c\u4f46\u662f\u6b64\u65f6HEAD\u4f1a\u5904\u4e8e\u6e38\u79bb\u7684\u72b6\u6001\u3002<br \/>\n<img src=\"http:\/\/xinyiworld.top\/wordpress\/wp-content\/uploads\/2022\/01\/9E5622B7-D622-4745-B075-633769844CEB.png\" alt=\"\" \/><\/p>\n<p><a href=\"https:\/\/blog.csdn.net\/adojayfan\/article\/details\/88808354\">https:\/\/blog.csdn.net\/adojayfan\/article\/details\/88808354<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"%E5%90%88%E5%B9%B6\"><\/span>\u5408\u5e76<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<h4><span class=\"ez-toc-section\" id=\"%E5%8F%98%E5%9F%BA%EF%BC%88rebase%EF%BC%89\"><\/span>\u53d8\u57fa\uff08rebase\uff09<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p><code>rebase -i<\/code>\uff1a\u7684i\u5c31\u662finteractive\uff0c\u4ea4\u4e92\u7684\u610f\u601d\u3002<\/p>\n<p>\u5c06\u63d0\u4ea4\u5230\u67d0\u4e00\u5206\u652f\u4e0a\u7684\u6240\u6709\u4fee\u6539\u6216\u8005\u90e8\u5206\u4fee\u6539\u90fd\u79fb\u81f3\u53e6\u4e00\u5206\u652f\u4e0a\uff0c\u5c31\u597d\u50cf\u201c\u91cd\u65b0\u64ad\u653e\u201d\u4e00\u6837\u3002<\/p>\n<p><a href=\"https:\/\/git-scm.com\/book\/zh\/v2\/Git-%E5%88%86%E6%94%AF-%E5%8F%98%E5%9F%BA\">https:\/\/git-scm.com\/book\/zh\/v2\/Git-%E5%88%86%E6%94%AF-%E5%8F%98%E5%9F%BA<\/a><\/p>\n<p><a href=\"https:\/\/zhuanlan.zhihu.com\/p\/271677627\">https:\/\/zhuanlan.zhihu.com\/p\/271677627<\/a>(\u77e5\u4e4e\uff0c\u8bb2\u89e3\u5f97\u5f88\u5bb9\u6613\u7406\u89e3)<\/p>\n<p><a href=\"https:\/\/www.jianshu.com\/p\/4a8f4af4e803\">https:\/\/www.jianshu.com\/p\/4a8f4af4e803<\/a><\/p>\n<pre><code class=\"language-shell\">pick\uff1a\u4fdd\u7559\u8be5commit\uff08\u7f29\u5199:p\uff09\nreword\uff1a\u4fdd\u7559\u8be5commit\uff0c\u4f46\u6211\u9700\u8981\u4fee\u6539\u8be5commit\u7684\u6ce8\u91ca\uff08\u7f29\u5199:r\uff09\nedit\uff1a\u4fdd\u7559\u8be5commit, \u4f46\u6211\u8981\u505c\u4e0b\u6765\u4fee\u6539\u8be5\u63d0\u4ea4(\u4e0d\u4ec5\u4ec5\u4fee\u6539\u6ce8\u91ca)\uff08\u7f29\u5199:e\uff09\nsquash\uff1a\u5c06\u8be5commit\u548c\u524d\u4e00\u4e2acommit\u5408\u5e76\uff08\u7f29\u5199:s\uff09\nfixup\uff1a\u5c06\u8be5commit\u548c\u524d\u4e00\u4e2acommit\u5408\u5e76\uff0c\u4f46\u6211\u4e0d\u8981\u4fdd\u7559\u8be5\u63d0\u4ea4\u7684\u6ce8\u91ca\u4fe1\u606f\uff08\u7f29\u5199:f\uff09\nexec\uff1a\u6267\u884cshell\u547d\u4ee4\uff08\u7f29\u5199:x\uff09\ndrop\uff1a\u6211\u8981\u4e22\u5f03\u8be5commit\uff08\u7f29\u5199:d\uff09<\/code><\/pre>\n<p>\u4f5c\u7528\uff1a\u5408\u5e76\u5206\u652f\uff0c\u5408\u5e76\u63d0\u4ea4\uff0c\u5220\u9664\u63d0\u4ea4\u7b49\u3002<\/p>\n<h4><span class=\"ez-toc-section\" id=\"cherry-pick\"><\/span>cherry-pick<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>\u5c06\u6307\u5b9a\u7684\u63d0\u4ea4\uff08commit\uff09\u5e94\u7528\u4e8e\u5176\u4ed6\u5206\u652f\u3002<br \/>\n<a href=\"http:\/\/www.ruanyifeng.com\/blog\/2020\/04\/git-cherry-pick.html\">http:\/\/www.ruanyifeng.com\/blog\/2020\/04\/git-cherry-pick.html<\/a><\/p>\n<p>\u5047\u5982\uff1amaster\u5206\u652f:C1-C2\uff0c\u7136\u540e\u4eceC2 fork\u51fa\u4e86dev\u5206\u652f\uff0cdev\u521b\u5efa\u4e86C3-C4-C5-C6\u63d0\u4ea4\u3002\u73b0\u5728\u8981\u628aC5-C6\u5e94\u7528\u5230master\u7684\u5206\u652f\u7684C2\u4e0a.\u90a3\u4e48\u9700\u8981\u6267\u884c\u7684\u547d\u4ee4\u662f\uff1a<\/p>\n<pre><code class=\"language-shell\">#\u5207\u6362\u5230master-C2\u4e0a\ngit checkout master\n#\u5c06C5-C6\u63a5\u5165\u5230master-C2\u4e0a\ngit cherry-pick dev-C5\u7684\u63d0\u4ea4id   dev-C6\u7684\u63d0\u4ea4id\n\u4e0a\u9762\u8fd9\u53e5\u547d\u4ee4\u6267\u884c\u7684\u5177\u4f53\u64cd\u4f5c\u662f\uff1a\n\u5c06dev-C5\u4e0emaster-C2\u5408\u5e76\u751f\u6210\u65b0\u7684\u63d0\u4ea4C5&#039;\uff0cC5&#039;\u518d\u4e0edev-C6\u5408\u5e76\u751f\u6210\u65b0\u7684\u63d0\u4ea4C6&#039;\u3002\n\u5982\u679c\u5408\u5e76\u6709\u51b2\u7a81\uff0c\u9700\u8981\u89e3\u51b3\u51b2\u7a81\u540e\u6267\u884cgit add\u548cgit cherry-pick --continue\u64cd\u4f5c\u3002<\/code><\/pre>\n<h4><span class=\"ez-toc-section\" id=\"merge\"><\/span>merge<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<ul>\n<li>\u5408\u5e76\u51b2\u7a81<br \/>\n<a href=\"https:\/\/www.php.cn\/faq\/509655.html\">https:\/\/www.php.cn\/faq\/509655.html<\/a><\/li>\n<\/ul>\n<p>\u67e5\u770b\u51b2\u7a81\u6587\u4ef6\uff1a<code>git\u00a0diff\u00a0--name-only\u00a0--diff-filter=U<\/code><br \/>\n\u67e5\u770b\u51b2\u7a81\u4f4d\u7f6e\uff1a\u641c\u7d22<code>&gt;&gt;&gt;&gt;&gt;&gt;<\/code>\u6807\u8bb0<\/p>\n<h3><span class=\"ez-toc-section\" id=\"%E8%B4%AE%E8%97%8F%E4%B8%8E%E6%B8%85%E7%90%86\"><\/span>\u8d2e\u85cf\u4e0e\u6e05\u7406<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u5e38\u7528\u4e8e\u60f3\u4fdd\u5b58\u5f53\u524d\u7684\u4fee\u6539\uff0c\u4f46\u662f\u53c8\u4e0d\u60f3commit\u7684\u573a\u666f\u3002<\/p>\n<p><a href=\"https:\/\/git-scm.com\/book\/zh\/v2\/Git-%E5%B7%A5%E5%85%B7-%E8%B4%AE%E8%97%8F%E4%B8%8E%E6%B8%85%E7%90%86\">https:\/\/git-scm.com\/book\/zh\/v2\/Git-%E5%B7%A5%E5%85%B7-%E8%B4%AE%E8%97%8F%E4%B8%8E%E6%B8%85%E7%90%86<\/a><\/p>\n<p><a href=\"https:\/\/blog.csdn.net\/stone_yw\/article\/details\/80795669\">https:\/\/blog.csdn.net\/stone_yw\/article\/details\/80795669<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"%E6%9F%A5%E7%9C%8B%E5%8E%86%E5%8F%B2%E8%AE%B0%E5%BD%95\"><\/span>\u67e5\u770b\u5386\u53f2\u8bb0\u5f55<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li>\n<p>git reflog<br \/>\n\u663e\u793a\u64cd\u4f5c\u65e5\u671f\uff1agit reflog --date=iso<\/p>\n<\/li>\n<li>\n<p>\u67e5\u770b\u67d0\u6b21\u63d0\u4ea4\u4fee\u6539\u7684\u6587\u4ef6\uff0c\u4ec5\u67e5\u770b\u6587\u4ef6\u540d\uff0c\u4e0d\u67e5\u770b\u5185\u5bb9<br \/>\n<code>git show &lt;commit_id&gt; --raw<\/code>\u6216<code>git show --name-only [commit_id]<\/code><\/p>\n<\/li>\n<\/ul>\n<p>git log \u67e5\u770bcommit\u7684\u5386\u53f2<br \/>\ngit show \u67e5\u770b\u67d0\u6b21commit\u7684\u4fee\u6539\u5185\u5bb9<br \/>\ngit log -p \u67e5\u770b\u67d0\u4e2a\u6587\u4ef6\u7684\u4fee\u6539\u5386\u53f2<br \/>\ngit log -p -2\u67e5\u770b\u6700\u8fd12\u6b21\u7684\u66f4\u65b0\u5185\u5bb9<br \/>\ngit log \u2013name-status \u6bcf\u6b21\u4fee\u6539\u7684\u6587\u4ef6\u5217\u8868, \u663e\u793a\u72b6\u6001<br \/>\ngit log \u2013name-only \u6bcf\u6b21\u4fee\u6539\u7684\u6587\u4ef6\u5217\u8868<br \/>\ngit log \u2013stat \u6bcf\u6b21\u4fee\u6539\u7684\u6587\u4ef6\u5217\u8868, \u53ca\u6587\u4ef6\u4fee\u6539\u7684\u7edf\u8ba1<br \/>\ngit whatchanged \u6bcf\u6b21\u4fee\u6539\u7684\u6587\u4ef6\u5217\u8868<br \/>\ngit whatchanged \u2013stat \u6bcf\u6b21\u4fee\u6539\u7684\u6587\u4ef6\u5217\u8868, \u53ca\u6587\u4ef6\u4fee\u6539\u7684\u7edf\u8ba1<br \/>\ngit show \u663e\u793a\u6700\u540e\u4e00\u6b21\u7684\u6587\u4ef6\u6539\u53d8\u7684\u5177\u4f53\u5185\u5bb9<\/p>\n<ul>\n<li>\u67e5\u770b\u67d0\u4e2a\u6587\u4ef6\u7684\u4fee\u6539\u5386\u53f2<\/li>\n<\/ul>\n<p>git log filename \u53ef\u4ee5\u770b\u5230fileName\u76f8\u5173\u7684commit\u8bb0\u5f55<br \/>\ngit log -p filename \u53ef\u4ee5\u663e\u793afilename\u6bcf\u6b21\u63d0\u4ea4\u7684diff<\/p>\n<p>\u53ea\u770b\u67d0\u6b21commit\u63d0\u4ea4\u4e2d\u7684\u67d0\u4e2a\u6587\u4ef6\u53d8\u5316\uff0c\u53ef\u4ee5\u76f4\u63a5\u52a0\u4e0afileName\uff1a git show commit_id filename<\/p>\n<h3><span class=\"ez-toc-section\" id=\"%E9%87%8D%E5%91%BD%E5%90%8D%E5%88%86%E6%94%AF\"><\/span>\u91cd\u547d\u540d\u5206\u652f<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>git branch -M \u539f\u5206\u652f\u540d  \u65b0\u5206\u652f\u540d<\/p>\n<h3><span class=\"ez-toc-section\" id=\"%E5%88%A0%E9%99%A4%E8%BF%9C%E7%A8%8B%E5%88%86%E6%94%AF\"><\/span>\u5220\u9664\u8fdc\u7a0b\u5206\u652f<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>git push origin --delete [branch_name]<\/p>\n<h3><span class=\"ez-toc-section\" id=\"%E6%96%B0%E5%BB%BA%E5%B9%B6%E5%88%87%E6%8D%A2%E5%88%86%E6%94%AF\"><\/span>\u65b0\u5efa\u5e76\u5207\u6362\u5206\u652f<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>git switch -c feature1<\/p>\n<h3><span class=\"ez-toc-section\" id=\"%E5%88%86%E6%94%AF%E5%AF%B9%E6%AF%94%E5%91%BD%E4%BB%A4\"><\/span>\u5206\u652f\u5bf9\u6bd4\u547d\u4ee4<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><a href=\"https:\/\/blog.csdn.net\/qq_33192454\/article\/details\/132079072\">https:\/\/blog.csdn.net\/qq_33192454\/article\/details\/132079072<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"%E5%88%A0%E9%99%A4%E6%89%80%E6%9C%89_Commit_%E6%8F%90%E4%BA%A4%E8%AE%B0%E5%BD%95\"><\/span>\u5220\u9664\u6240\u6709 Commit \u63d0\u4ea4\u8bb0\u5f55<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<pre><code class=\"language-bash\">1.\u521b\u5efa\u5b64\u7acb\u5206\u652f\uff0c\u5e76\u5207\u6362\u5230\u8be5\u5206\u652f\uff1a\ngit checkout --orphan latest_branch\n\n2. \u6682\u5b58\u6240\u6709\u6587\u4ef6\uff1a\ngit add -A\n\n3. \u63d0\u4ea4\u6240\u6709\u66f4\u6539\uff1a\ngit commit -am &quot;First Commit&quot;\n\n4. \u5220\u9664\u4e3b\u5206\u652f master\uff1a\ngit branch -D master\n\n5. \u91cd\u547d\u540d\u5f53\u524d\u5206\u652f\u4e3a master\uff1a\ngit branch -m master\n\n6. \u5f3a\u5236\u63a8\u9001\u672c\u5730\u5206\u652f\uff1a\ngit push -f origin master<\/code><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"%E6%A0%87%E7%AD%BE%E6%93%8D%E4%BD%9C\"><\/span>\u6807\u7b7e\u64cd\u4f5c<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><a href=\"https:\/\/blog.csdn.net\/m0_45406092\/article\/details\/128804574\">https:\/\/blog.csdn.net\/m0_45406092\/article\/details\/128804574<\/a><br \/>\n\u6ce8\u610f\u6807\u7b7e\u9ed8\u8ba4\u662f\u4e0d\u4f1a\u81ea\u52a8\u63d0\u4ea4\u7684<\/p>\n<h3><span class=\"ez-toc-section\" id=\"%E6%9B%B4%E6%8D%A2%E8%BF%9C%E7%A8%8B%E5%9C%B0%E5%9D%80\"><\/span>\u66f4\u6362\u8fdc\u7a0b\u5730\u5740<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><a href=\"http:\/\/www.taodudu.cc\/news\/show-112960.html?action=onClick\">http:\/\/www.taodudu.cc\/news\/show-112960.html?action=onClick<\/a><\/p>\n<pre><code class=\"language-bash\">git remote \u67e5\u770b\u6240\u6709\u8fdc\u7a0b\u4ed3\u5e93\uff0c git remote xxx \u67e5\u770b\u6307\u5b9a\u8fdc\u7a0b\u4ed3\u5e93\u5730\u5740\ngit remote rm origin\ngit remote add origin http:\/\/192.168.100.235:9797\/john\/git_test.git<\/code><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"%E4%BF%AE%E6%94%B9%E8%BF%9C%E7%A8%8B%E5%88%86%E6%94%AF%E5%90%8D%E7%A7%B0\"><\/span>\u4fee\u6539\u8fdc\u7a0b\u5206\u652f\u540d\u79f0<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<pre><code class=\"language-bash\">git branch -m old_branch new_branch  # \u91cd\u547d\u540d\u672c\u5730\u5206\u652f\ngit push origin :old_branch  # \u5220\u9664\u8fdc\u7a0b\u65e7\u7684\u5206\u652f\ngit push origin new_branch # \u63a8\u9001\u65b0\u7684\u5206\u652f\u5230\u8fdc\u7a0b\u4ed3\u5e93<\/code><\/pre>\n<button class=\"simplefavorite-button\" data-postid=\"5862\" data-siteid=\"1\" data-groupid=\"1\" data-favoritecount=\"0\" style=\"\">\u6536\u85cf <i class=\"sf-icon-star-empty\"><\/i><\/button>","protected":false},"excerpt":{"rendered":"<p>https:\/\/github.com\/github\/gitignore\/blob\/main\/Andr [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[358],"tags":[],"_links":{"self":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/5862"}],"collection":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5862"}],"version-history":[{"count":49,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/5862\/revisions"}],"predecessor-version":[{"id":14496,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/5862\/revisions\/14496"}],"wp:attachment":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5862"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5862"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5862"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}