{"id":673,"date":"2023-06-03T16:07:29","date_gmt":"2023-06-03T08:07:29","guid":{"rendered":"https:\/\/niuguodong.com\/?p=673"},"modified":"2025-12-25T11:38:22","modified_gmt":"2025-12-25T03:38:22","slug":"git%e9%87%8d%e5%86%99%e5%8e%86%e5%8f%b2","status":"publish","type":"post","link":"https:\/\/niuguodong.com\/index.php\/2023\/06\/03\/git%e9%87%8d%e5%86%99%e5%8e%86%e5%8f%b2\/","title":{"rendered":"Git\u91cd\u5199\u5386\u53f2"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u4fee\u6539\u6700\u540e\u4e00\u6b21\u63d0\u4ea4<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code># \u53ea\u4fee\u6539\u63d0\u4ea4\u4fe1\u606f \ngit commit --amend\n# \u91cd\u65b0\u7f16\u8f91\u63d0\u4ea4\u4fe1\u606f\n\n# \u4fee\u6539\u5185\u5bb9\n# \u5148\u4fee\u6539\u597d\u5185\u5bb9\ngit add\ngit commit --amend\n# \u6216\u8005\ngit commit --amend --no-edit<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u6df1\u5ea6\u4fee\u6539\u5386\u53f2<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u4fee\u6539\u5386\u53f2\u4f5c\u8005\u4fe1\u606f<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>git filter-branch --commit-filter '\n        if &#91; \"$GIT_AUTHOR_EMAIL\" = \"schacon@localhost\" ];\n        then\n                GIT_AUTHOR_NAME=\"Scott Chacon\";\n                GIT_AUTHOR_EMAIL=\"schacon@example.com\";\n                git commit-tree \"$@\";\n        else\n                git commit-tree \"$@\";\n        fi' HEAD<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u79fb\u9664\u6240\u6709\u5386\u53f2\u63d0\u4ea4\u4e2d\u7684\u67d0\u4e2a\u6587\u4ef6<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>git filter-branch --tree-filter 'rm -f password.md' HEAD<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u5f3a\u5236\u63a8\u9001\u5230\u8fdc\u7a0b\u4ed3\u5e93<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>git push --force-with-lease origin dev<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u79fb\u9664\u672c\u5730\u7684\u65e7\u5386\u53f2<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>git for-each-ref --format='delete %(refname)' refs\/original | git update-ref --stdin\ngit gc --prune=now<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4fee\u6539\u6700\u540e\u4e00\u6b21\u63d0\u4ea4 \u6df1\u5ea6\u4fee\u6539\u5386\u53f2 \u4fee\u6539\u5386\u53f2\u4f5c\u8005\u4fe1\u606f \u79fb\u9664\u6240\u6709\u5386\u53f2\u63d0\u4ea4\u4e2d\u7684\u67d0\u4e2a\u6587\u4ef6 \u5f3a\u5236\u63a8\u9001\u5230\u8fdc\u7a0b\u4ed3\u5e93 \u79fb\u9664\u672c\u5730\u7684 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[6,5],"tags":[],"class_list":["post-673","post","type-post","status-publish","format-standard","hentry","category-git","category-5"],"_links":{"self":[{"href":"https:\/\/niuguodong.com\/index.php\/wp-json\/wp\/v2\/posts\/673","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/niuguodong.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/niuguodong.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/niuguodong.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/niuguodong.com\/index.php\/wp-json\/wp\/v2\/comments?post=673"}],"version-history":[{"count":0,"href":"https:\/\/niuguodong.com\/index.php\/wp-json\/wp\/v2\/posts\/673\/revisions"}],"wp:attachment":[{"href":"https:\/\/niuguodong.com\/index.php\/wp-json\/wp\/v2\/media?parent=673"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/niuguodong.com\/index.php\/wp-json\/wp\/v2\/categories?post=673"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/niuguodong.com\/index.php\/wp-json\/wp\/v2\/tags?post=673"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}