{"id":21578,"date":"2024-11-19T11:59:46","date_gmt":"2024-11-19T03:59:46","guid":{"rendered":"https:\/\/fwq.ai\/blog\/21578\/"},"modified":"2024-11-19T11:59:46","modified_gmt":"2024-11-19T03:59:46","slug":"git%e6%80%8e%e4%b9%88%e5%88%9b%e5%bb%ba%e8%87%aa%e5%b7%b1%e7%9a%84%e5%88%86%e6%94%af","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/21578\/","title":{"rendered":"git\u600e\u4e48\u521b\u5efa\u81ea\u5df1\u7684\u5206\u652f"},"content":{"rendered":"<blockquote><p>\n  \u5728 git \u4e2d\u521b\u5efa\u81ea\u5df1\u7684\u5206\u652f\uff0c\u9700\u4f9d\u6b21\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u83b7\u53d6\u6700\u65b0\u4ee3\u7801 (git pull)\u521b\u5efa\u65b0\u5206\u652f (git branch [\u5206\u652f\u540d])\u5207\u6362\u5230\u65b0\u5206\u652f (git checkout [\u5206\u652f\u540d])\u5f00\u53d1\u65b0\u529f\u80fd\u6216\u4fee\u590d\u9519\u8bef\u63d0\u4ea4\u66f4\u6539 (git commit -m &#8220;\u63d0\u4ea4\u6d88\u606f&#8221;)\u53ef\u9009\uff1a\u63a8\u9001\u5206\u652f\u5230\u8fdc\u7a0b\u670d\u52a1\u5668 (git push origin [\u5206\u652f\u540d])\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/31\/2024053100393016127.jpg\" class=\"aligncenter\" title=\"git\u600e\u4e48\u521b\u5efa\u81ea\u5df1\u7684\u5206\u652f\u63d2\u56fe\" alt=\"git\u600e\u4e48\u521b\u5efa\u81ea\u5df1\u7684\u5206\u652f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u4f7f\u7528 Git \u521b\u5efa\u81ea\u5df1\u7684\u5206\u652f<\/strong><\/p>\n<p><strong>\u7b80\u4ecb<\/strong><br \/>\u5728 Git \u7248\u672c\u63a7\u5236\u7cfb\u7edf\u4e2d\uff0c\u5206\u652f\u662f\u8ddf\u8e2a\u548c\u7ba1\u7406\u9879\u76ee\u4e2d\u4e0d\u540c\u7248\u672c\u7684\u624b\u6bb5\u3002\u521b\u5efa\u81ea\u5df1\u7684\u5206\u652f\u53ef\u8ba9\u4f60\u5728\u4e0d\u5f71\u54cd\u4e3b\u5206\u652f\u7684\u60c5\u51b5\u4e0b\u72ec\u7acb\u5f00\u53d1\u65b0\u529f\u80fd\u6216\u4fee\u590d\u9519\u8bef\u3002<\/p>\n<p><strong>\u6b65\u9aa4<\/strong><\/p>\n<p><strong>1. \u4ece\u8fdc\u7a0b\u670d\u52a1\u5668\u83b7\u53d6\u6700\u65b0\u4ee3\u7801<\/strong><br \/> pull<\/p>\n<p><strong>2. \u521b\u5efa\u65b0\u5206\u652f<\/strong><br \/>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u65b0\u5206\u652f\uff0c\u5176\u4e2d &#8220;my-branch&#8221; \u662f\u4f60\u5e0c\u671b\u4e3a\u65b0\u5206\u652f\u547d\u540d\u7684\u540d\u79f0\uff1a<br \/>git branch my-branch<\/p>\n<p><strong>3. \u5207\u6362\u5230\u65b0\u5206\u652f<\/strong><br \/>\u8981\u5f00\u59cb\u5728\u65b0\u5206\u652f\u4e0a\u5de5\u4f5c\uff0c\u4f60\u9700\u8981\u5207\u6362\u5230\u5b83\uff1a<br \/>git checkout my-branch<\/p>\n<p><strong>4. \u5f00\u53d1\u65b0\u529f\u80fd\u6216\u4fee\u590d\u9519\u8bef<\/strong><br \/>\u5728\u65b0\u5206\u652f\u4e0a\u5b8c\u6210\u6240\u9700\u7684\u5de5\u4f5c\u3002\u4f60\u53ef\u4ee5\u521b\u5efa\u65b0\u6587\u4ef6\u3001\u4fee\u6539\u73b0\u6709\u6587\u4ef6\u5e76\u63d0\u4ea4\u66f4\u6539\u3002<\/p>\n<p><strong>5. \u63d0\u4ea4\u66f4\u6539<\/strong><br \/>\u5f53\u4f60\u5bf9\u6240\u505a\u7684\u66f4\u6539\u611f\u5230\u6ee1\u610f\u540e\uff0c\u63d0\u4ea4\u5b83\u4eec\u5230\u4f60\u7684\u5206\u652f\uff1a<br \/>git commit -m &#8220;\u63d0\u4ea4\u6d88\u606f&#8221;<\/p>\n<p><strong>6. \u63a8\u9001\u5206\u652f\u5230\u8fdc\u7a0b\u670d\u52a1\u5668\uff08\u53ef\u9009\uff09<\/strong><br \/>\u5982\u679c\u4f60\u5e0c\u671b\u4e0e\u4ed6\u4eba\u5171\u4eab\u4f60\u7684\u66f4\u6539\u6216\u5728\u591a\u4e2a\u8ba1\u7b97\u673a\u4e0a\u5de5\u4f5c\uff0c\u8bf7\u5c06\u5206\u652f\u63a8\u9001\u5230\u8fdc\u7a0b\u670d\u52a1\u5668\uff1a<br \/>git push origin my-branch<\/p>\n<p><strong>\u540e\u7eed\u6b65\u9aa4<\/strong><\/p>\n<ul>\n<li>\u5f53\u4f60\u5b8c\u6210\u5728\u5206\u652f\u4e0a\u7684\u5de5\u4f5c\u65f6\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 git checkout master \u5207\u6362\u56de\u4e3b\u5206\u652f\u3002<\/li>\n<li>\u5982\u679c\u4f60\u60f3\u4fdd\u7559\u5206\u652f\u4ee5\u4fbf\u5c06\u6765\u7ee7\u7eed\u5de5\u4f5c\uff0c\u53ef\u4ee5\u901a\u8fc7 git stash \u5c06\u5b83\u6401\u7f6e\uff0c\u7136\u540e\u518d\u7a0d\u540e\u6062\u590d\u3002<\/li>\n<li>\u5982\u679c\u4f60\u4e0d\u518d\u9700\u8981\u5206\u652f\uff0c\u53ef\u4ee5\u4f7f\u7528 git branch -d my-branch \u5220\u9664\u5b83\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u521b\u5efa\u81ea\u5df1\u7684\u5206\u652f\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 git \u4e2d\u521b\u5efa\u81ea\u5df1\u7684\u5206\u652f\uff0c\u9700\u4f9d\u6b21\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u83b7\u53d6\u6700\u65b0\u4ee3\u7801 (git pull)\u521b\u5efa\u65b0\u5206\u652f (git branch [\u5206\u652f\u540d])\u5207\u6362\u5230\u65b0\u5206\u652f (git checkout [\u5206\u652f\u540d])\u5f00\u53d1\u65b0\u529f\u80fd\u6216\u4fee\u590d\u9519\u8bef\u63d0\u4ea4\u66f4\u6539 (git commit -m &#8220;\u63d0\u4ea4\u6d88\u606f&#8221;)\u53ef\u9009\uff1a\u63a8\u9001\u5206\u652f\u5230\u8fdc\u7a0b\u670d\u52a1\u5668 (git push origin [\u5206\u652f\u540d]) \u5982\u4f55\u4f7f\u7528 Git \u521b\u5efa\u81ea\u5df1\u7684\u5206\u652f \u7b80\u4ecb\u5728 Git \u7248\u672c\u63a7\u5236\u7cfb\u7edf\u4e2d\uff0c\u5206\u652f\u662f\u8ddf\u8e2a\u548c\u7ba1\u7406\u9879\u76ee\u4e2d\u4e0d\u540c\u7248\u672c\u7684\u624b\u6bb5\u3002\u521b\u5efa\u81ea\u5df1\u7684\u5206\u652f\u53ef\u8ba9\u4f60\u5728\u4e0d\u5f71\u54cd\u4e3b\u5206\u652f\u7684\u60c5\u51b5\u4e0b\u72ec\u7acb\u5f00\u53d1\u65b0\u529f\u80fd\u6216\u4fee\u590d\u9519\u8bef\u3002 \u6b65\u9aa4 1. \u4ece\u8fdc\u7a0b\u670d\u52a1\u5668\u83b7\u53d6\u6700\u65b0\u4ee3\u7801 pull 2. \u521b\u5efa\u65b0\u5206\u652f\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u65b0\u5206\u652f\uff0c\u5176\u4e2d &#8220;my-branch&#8221; \u662f\u4f60\u5e0c\u671b\u4e3a\u65b0\u5206\u652f\u547d\u540d\u7684\u540d\u79f0\uff1agit branch my-branch 3. \u5207\u6362\u5230\u65b0\u5206\u652f\u8981\u5f00\u59cb\u5728\u65b0\u5206\u652f\u4e0a\u5de5\u4f5c\uff0c\u4f60\u9700\u8981\u5207\u6362\u5230\u5b83\uff1agit checkout my-branch 4. \u5f00\u53d1\u65b0\u529f\u80fd\u6216\u4fee\u590d\u9519\u8bef\u5728\u65b0\u5206\u652f\u4e0a\u5b8c\u6210\u6240\u9700\u7684\u5de5\u4f5c\u3002\u4f60\u53ef\u4ee5\u521b\u5efa\u65b0\u6587\u4ef6\u3001\u4fee\u6539\u73b0\u6709\u6587\u4ef6\u5e76\u63d0\u4ea4\u66f4\u6539\u3002 5. \u63d0\u4ea4\u66f4\u6539\u5f53\u4f60\u5bf9\u6240\u505a\u7684\u66f4\u6539\u611f\u5230\u6ee1\u610f\u540e\uff0c\u63d0\u4ea4\u5b83\u4eec\u5230\u4f60\u7684\u5206\u652f\uff1agit commit -m &#8220;\u63d0\u4ea4\u6d88\u606f&#8221; 6. \u63a8\u9001\u5206\u652f\u5230\u8fdc\u7a0b\u670d\u52a1\u5668\uff08\u53ef\u9009\uff09\u5982\u679c\u4f60\u5e0c\u671b\u4e0e\u4ed6\u4eba\u5171\u4eab\u4f60\u7684\u66f4\u6539\u6216\u5728\u591a\u4e2a\u8ba1\u7b97\u673a\u4e0a\u5de5\u4f5c\uff0c\u8bf7\u5c06\u5206\u652f\u63a8\u9001\u5230\u8fdc\u7a0b\u670d\u52a1\u5668\uff1agit push origin my-branch \u540e\u7eed\u6b65\u9aa4 \u5f53\u4f60\u5b8c\u6210\u5728\u5206\u652f\u4e0a\u7684\u5de5\u4f5c\u65f6\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 git checkout [&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-21578","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21578","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=21578"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21578\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=21578"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=21578"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=21578"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}