{"id":19137,"date":"2024-11-19T11:52:34","date_gmt":"2024-11-19T03:52:34","guid":{"rendered":"https:\/\/fwq.ai\/blog\/19137\/"},"modified":"2024-11-19T11:52:34","modified_gmt":"2024-11-19T03:52:34","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8git%e5%88%a0%e9%99%a4%e8%bf%9c%e7%a8%8b%e4%bb%93%e5%ba%93","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/19137\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528Git\u5220\u9664\u8fdc\u7a0b\u4ed3\u5e93"},"content":{"rendered":"<p>\u5728\u4f7f\u7528git\u8fdb\u884c\u5f00\u53d1\u65f6\uff0c\u6709\u65f6\u6211\u4eec\u9700\u8981\u5220\u9664\u8fdc\u7a0b\u4ed3\u5e93\u4e2d\u7684\u4e00\u4e9b\u6587\u4ef6\u6216\u8005\u6574\u4e2a\u4ed3\u5e93\u3002\u672c\u6587\u5c06\u5411\u4f60\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528git\u5220\u9664\u8fdc\u7a0b\u4ed3\u5e93\u3002<\/p>\n<p>\u4e00\u3001\u5220\u9664\u8fdc\u7a0b\u4ed3\u5e93\u4e2d\u7684\u6587\u4ef6<\/p>\n<p>1.\u8fdb\u5165\u672c\u5730\u4ed3\u5e93\u76ee\u5f55\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5c06\u6587\u4ef6\u5220\u9664\uff1a<\/p>\n<pre>git rm file.txt<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>2.\u63d0\u4ea4\u66f4\u6539\uff0c\u5c06\u672c\u5730\u7684\u66f4\u6539\u63a8\u9001\u5230\u8fdc\u7a0b\u4ed3\u5e93\uff1a<\/p>\n<pre>git commit -m \"delete file.txt\"\ngit push origin master<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4e8c\u3001\u5220\u9664\u8fdc\u7a0b\u4ed3\u5e93\u4e2d\u7684\u5206\u652f<\/p>\n<p>1.\u67e5\u770b\u8fdc\u7a0b\u5206\u652f\uff1a<\/p>\n<pre>git branch -r<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>2.\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5220\u9664\u8fdc\u7a0b\u5206\u652f\uff1a<\/p>\n<pre>git push origin --delete branchName<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>3.\u66f4\u65b0\u672c\u5730\u4ee3\u7801\uff1a<\/p>\n<pre>git pull<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4e09\u3001\u5220\u9664\u8fdc\u7a0b\u4ed3\u5e93<\/p>\n<p>1.\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5220\u9664\u8fdc\u7a0b\u4ed3\u5e93\uff1a<\/p>\n<pre>git remote rm origin<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>2.\u786e\u8ba4\u5df2\u7ecf\u5220\u9664\uff1a<\/p>\n<pre>git remote -v<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>3.\u5220\u9664\u672c\u5730\u4ed3\u5e93\u4e2d\u76f8\u5173\u7684\u8fdc\u7a0b\u8ddf\u8e2a\u5206\u652f\uff1a<\/p>\n<pre>git branch -r | awk -F\/ '{if($1==\"origin\") print $2}' | xargs git branch -d -r<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u56db\u3001\u5c0f\u7ed3<\/p>\n<p>Git\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u547d\u4ee4\uff0c\u8ba9\u6211\u4eec\u53ef\u4ee5\u8f7b\u677e\u5730\u7ba1\u7406\u7248\u672c\u63a7\u5236\uff0c\u5305\u62ec\u5220\u9664\u8fdc\u7a0b\u4ed3\u5e93\u4e2d\u7684\u6587\u4ef6\u3001\u5206\u652f\u548c\u4ed3\u5e93\u3002\u4f46\u662f\uff0c\u4e00\u5b9a\u8981\u8c28\u614e\u4f7f\u7528\u5220\u9664\u547d\u4ee4\uff0c\u786e\u4fdd\u5220\u9664\u7684\u5bf9\u8c61\u662f\u6b63\u786e\u7684\u3002\u5982\u679c\u4e0d\u786e\u5b9a\uff0c\u53ef\u4ee5\u5728\u5220\u9664\u524d\u505a\u597d\u5907\u4efd\u6216\u8005\u5148\u5728\u672c\u5730\u6d4b\u8bd5\u4e00\u4e0b\u518d\u8fdb\u884c\u5220\u9664\u64cd\u4f5c\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f7f\u7528Git\u5220\u9664\u8fdc\u7a0b\u4ed3\u5e93\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>\u5728\u4f7f\u7528git\u8fdb\u884c\u5f00\u53d1\u65f6\uff0c\u6709\u65f6\u6211\u4eec\u9700\u8981\u5220\u9664\u8fdc\u7a0b\u4ed3\u5e93\u4e2d\u7684\u4e00\u4e9b\u6587\u4ef6\u6216\u8005\u6574\u4e2a\u4ed3\u5e93\u3002\u672c\u6587\u5c06\u5411\u4f60\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528git\u5220\u9664\u8fdc\u7a0b\u4ed3\u5e93\u3002 \u4e00\u3001\u5220\u9664\u8fdc\u7a0b\u4ed3\u5e93\u4e2d\u7684\u6587\u4ef6 1.\u8fdb\u5165\u672c\u5730\u4ed3\u5e93\u76ee\u5f55\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5c06\u6587\u4ef6\u5220\u9664\uff1a git rm file.txt \u767b\u5f55\u540e\u590d\u5236 2.\u63d0\u4ea4\u66f4\u6539\uff0c\u5c06\u672c\u5730\u7684\u66f4\u6539\u63a8\u9001\u5230\u8fdc\u7a0b\u4ed3\u5e93\uff1a git commit -m &#8220;delete file.txt&#8221; git push origin master \u767b\u5f55\u540e\u590d\u5236 \u4e8c\u3001\u5220\u9664\u8fdc\u7a0b\u4ed3\u5e93\u4e2d\u7684\u5206\u652f 1.\u67e5\u770b\u8fdc\u7a0b\u5206\u652f\uff1a git branch -r \u767b\u5f55\u540e\u590d\u5236 2.\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5220\u9664\u8fdc\u7a0b\u5206\u652f\uff1a git push origin &#8211;delete branchName \u767b\u5f55\u540e\u590d\u5236 3.\u66f4\u65b0\u672c\u5730\u4ee3\u7801\uff1a git pull \u767b\u5f55\u540e\u590d\u5236 \u4e09\u3001\u5220\u9664\u8fdc\u7a0b\u4ed3\u5e93 1.\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5220\u9664\u8fdc\u7a0b\u4ed3\u5e93\uff1a git remote rm origin \u767b\u5f55\u540e\u590d\u5236 2.\u786e\u8ba4\u5df2\u7ecf\u5220\u9664\uff1a git remote -v \u767b\u5f55\u540e\u590d\u5236 3.\u5220\u9664\u672c\u5730\u4ed3\u5e93\u4e2d\u76f8\u5173\u7684\u8fdc\u7a0b\u8ddf\u8e2a\u5206\u652f\uff1a git branch -r | awk -F\/ &#8216;{if($1==&#8221;origin&#8221;) [&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-19137","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/19137","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=19137"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/19137\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=19137"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=19137"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=19137"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}