{"id":619,"date":"2025-03-28T12:05:30","date_gmt":"2025-03-28T04:05:30","guid":{"rendered":"https:\/\/znl.pub\/?p=619"},"modified":"2025-04-03T11:40:27","modified_gmt":"2025-04-03T03:40:27","slug":"%e3%80%90%e5%b9%b2%e8%b4%a7%e5%90%88%e9%9b%86%e3%80%91git-%e5%b8%b8%e7%94%a8%e6%93%8d%e4%bd%9c","status":"publish","type":"post","link":"https:\/\/znl.pub\/?p=619","title":{"rendered":"\u3010\u5e72\u8d27\u5408\u96c6\u3011git \u5e38\u7528\u64cd\u4f5c"},"content":{"rendered":"\n<details class=\"wp-block-details is-layout-flow wp-block-details-is-layout-flow\"><summary>\u5982\u4f55\u67e5\u770b\u4e24\u4e2a\uff08\u63d0\u4ea4|\u7248\u672c|\u6807\u7b7e\uff09\u4e4b\u95f4\u6709\u54ea\u4e9b\u6587\u4ef6\u88ab\u4fee\u6539\u8fc7<br><\/summary>\n<h3 class=\"wp-block-heading\"><strong>\u5217\u51fa\u53d8\u5316\u7684\u6587\u4ef6\u5217\u8868<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># \u6bd4\u8f83\u4e24\u4e2a\u63d0\u4ea4\u4e4b\u95f4\u7684\u5dee\u5f02\uff0c\u4ec5\u663e\u793a\u6587\u4ef6\u540d\uff08commit1\u548ccommit2\u662f\u4e24\u4e2a\u7248\u672c\u7684\u4fee\u8ba2\u53f7\uff0c1\u4e3a\u65e7\u7248\u672c\uff0c2\u4e3a\u65b0\u7248\u672c\uff09\ngit diff &lt;commit1&gt; &lt;commit2&gt; --name-only\n\n# \u4e0d\u77e5\u9053\u4fee\u8ba2\u53f7\uff0c\u53ef\u4ee5\u4f7f\u7528 HEAD\u6bd4\u8f83\u5f53\u524d\u7248\u672c\u548c\u4e4b\u524d\u7684\u7248\u672c\uff08\u6bd4\u5982\u524d1\u4e2a\u7248\u672c\uff09\ngit diff  HEAD~1  HEAD --name-only<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"> <strong><strong>\u5217\u51fa\u6587\u4ef6\u53ca\u5176\u53d8\u5316\u7c7b\u578b<\/strong>\uff08\u589e\/\u5220\/\u6539\uff09<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># \u663e\u793a\u6587\u4ef6\u540d\u53ca\u53d8\u5316\u72b6\u6001\uff08A:\u65b0\u589e, M:\u4fee\u6539, D:\u5220\u9664\uff09\ngit diff &lt;commit1&gt; &lt;commit2&gt; --name-status\n\n# \u6bd4\u8f83\u5f53\u524d\u5206\u652f\u4e0e\u67d0\u4e2a\u6807\u7b7e\ngit diff v1.0.0 HEAD --name-status<\/code><\/pre>\n<\/details>\n\n\n\n<details class=\"wp-block-details is-layout-flow wp-block-details-is-layout-flow\"><summary>git\u5728\u5b8c\u6210\u514b\u9686\u540e\u5217\u51fa\u6240\u6709\u5206\u652f\u5e76\u5207\u6362\u5230\u6307\u5b9a\u5206\u652f<\/summary>\n<h3 class=\"wp-block-heading\">\u514b\u9686\u4ed3\u5e93\u540e\u8fdb\u5165\u76ee\u5f55<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>git clone &lt;\u8fdc\u7a0b\u4ed3\u5e93\u5730\u5740&gt;   # \u514b\u9686\u4ed3\u5e93\u5230\u672c\u5730\ncd &lt;\u4ed3\u5e93\u76ee\u5f55\u540d&gt;           # \u8fdb\u5165\u514b\u9686\u7684\u4ed3\u5e93\u76ee\u5f55<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u5217\u51fa\u6240\u6709\u5206\u652f<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># \u67e5\u770b\u672c\u5730\u5206\u652f\ngit branch             # \u672c\u5730\u5206\u652f\u5217\u8868\uff0c\u5f53\u524d\u5206\u652f\u7528*\u6807\u8bb0\n\n# \u67e5\u770b\u8fdc\u7a0b\u5206\u652f\ngit branch -r          # \u8fdc\u7a0b\u5206\u652f\u5217\u8868\uff08\u4ee5remotes\/origin\/\u5f00\u5934\uff09\n\n# \u67e5\u770b\u6240\u6709\u5206\u652f\uff08\u672c\u5730+\u8fdc\u7a0b\uff09\ngit branch -a          # \u663e\u793a\u5168\u90e8\u672c\u5730\u548c\u8fdc\u7a0b\u5206\u652f<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u5207\u6362\u5206\u652f<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># \u5207\u6362\u5230\u5df2\u5b58\u5728\u7684\u672c\u5730\u5206\u652f\ngit checkout &lt;\u5206\u652f\u540d&gt;   # \u4f8b\u5982\uff1agit checkout dev\n\n# \u4ece\u8fdc\u7a0b\u5206\u652f\u521b\u5efa\u5e76\u5207\u6362\u5230\u65b0\u672c\u5730\u5206\u652f\ngit checkout -b &lt;\u672c\u5730\u5206\u652f\u540d&gt; origin\/&lt;\u8fdc\u7a0b\u5206\u652f\u540d&gt;  \n# \u4f8b\u5982\uff1agit checkout -b feature origin\/feature\n\n# \u5feb\u901f\u8fd4\u56de\u4e0a\u4e00\u4e2a\u5206\u652f\ngit checkout -          # \u5207\u6362\u56de\u4e0a\u4e00\u6b21\u64cd\u4f5c\u7684\u5206\u652f<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u8865\u5145\u8bf4\u660e<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u5408\u5e76\u51b2\u7a81\u5904\u7406<\/strong>\uff1a \u5207\u6362\u5206\u652f\u524d\u82e5\u5b58\u5728\u672a\u63d0\u4ea4\u7684\u4fee\u6539\uff0c\u9700\u5148\u63d0\u4ea4\u6216\u6682\u5b58\uff08<code>git stash<\/code>\uff09\uff0c\u5426\u5219\u4f1a\u63d0\u793a\u51b2\u7a81\u3002<\/li>\n\n\n\n<li><strong>\u540c\u6b65\u8fdc\u7a0b\u5206\u652f\u4fe1\u606f<\/strong>\uff1a \u5982\u679c\u53d1\u73b0\u8fdc\u7a0b\u5206\u652f\u672a\u663e\u793a\uff0c\u5148\u6267\u884c <code>git fetch<\/code> \u66f4\u65b0\u5206\u652f\u4fe1\u606f \u3002<\/li>\n\n\n\n<li><strong>\u5f3a\u5236\u5220\u9664\u672a\u5408\u5e76\u5206\u652f<\/strong>\uff1a \u82e5\u8bef\u64cd\u4f5c\u9700\u5220\u9664\u672a\u5408\u5e76\u7684\u5206\u652f\uff0c\u4f7f\u7528 <code>git branch -D &lt;\u5206\u652f\u540d><\/code> \u3002<\/li>\n<\/ul>\n<\/details>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22],"tags":[],"class_list":["post-619","post","type-post","status-publish","format-standard","hentry","category-22"],"_links":{"self":[{"href":"https:\/\/znl.pub\/index.php?rest_route=\/wp\/v2\/posts\/619","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/znl.pub\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/znl.pub\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/znl.pub\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/znl.pub\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=619"}],"version-history":[{"count":6,"href":"https:\/\/znl.pub\/index.php?rest_route=\/wp\/v2\/posts\/619\/revisions"}],"predecessor-version":[{"id":636,"href":"https:\/\/znl.pub\/index.php?rest_route=\/wp\/v2\/posts\/619\/revisions\/636"}],"wp:attachment":[{"href":"https:\/\/znl.pub\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=619"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/znl.pub\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=619"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/znl.pub\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=619"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}