{"id":37494,"date":"2023-02-18T02:11:58","date_gmt":"2023-06-24T09:25:44","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%85%b3%e4%ba%8egit-diff%e7%9a%84%e8%af%b4%e6%98%8e\/"},"modified":"2024-04-29T15:04:20","modified_gmt":"2024-04-29T07:04:20","slug":"%e5%85%b3%e4%ba%8egit-diff%e7%9a%84%e8%af%b4%e6%98%8e","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%85%b3%e4%ba%8egit-diff%e7%9a%84%e8%af%b4%e6%98%8e\/","title":{"rendered":"\u5173\u4e8egit diff\u7684\u8bf4\u660e"},"content":{"rendered":"<h1>\u56e0\u4e3a\u5728git diff\u4e2d\uff0c\u6211\u4e0d\u77e5\u9053&#8221;+&#8221;\u548c&#8221;-&#8220;\u8be5\u54ea\u4e2a\u662f\u54ea\u4e2a\uff0c\u6240\u4ee5\u9700\u8981\u786e\u8ba4\u4e00\u6b21\u3002<\/h1>\n<p>git\u65e5\u5fd7\u7684\u72b6\u6001<\/p>\n<pre class=\"post-pre\"><code><span class=\"nv\">$ <\/span>git log \r\ncommit eb59cf6d61d2c9b2a106d0d64cca976cad2efc44\r\nAuthor: kohei.shimadutsu\r\nDate:   Wed Jun 7 20:12:10 2017 +0900\r\n\r\n    third commit\r\n\r\ncommit 85448e9a9477f077a4904a48eb467585eb4f5015\r\nAuthor: kohei.shimadutsu\r\nDate:   Wed Jun 7 20:11:44 2017 +0900\r\n\r\n    second commit\r\n\r\ncommit f90d4dd80c16d7fa7f7b9cc9ed6827b0f4319170\r\nAuthor: kohei.shimadutsu\r\nDate:   Wed Jun 7 20:10:49 2017 +0900\r\n\r\n    initial commit\r\n\r\n<\/code><\/pre>\n<h2>git\u72b6\u6001<\/h2>\n<p>\u8bf7\u6ce8\u610f\uff0cREADME.md\u6587\u4ef6\u5df2\u6709\u66f4\u6539\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nv\">$ <\/span>git status\r\nOn branch master\r\nChanges not staged <span class=\"k\">for <\/span>commit:\r\n  <span class=\"o\">(<\/span>use <span class=\"s2\">\"git add &lt;file&gt;...\"<\/span> to update what will be committed<span class=\"o\">)<\/span>\r\n  <span class=\"o\">(<\/span>use <span class=\"s2\">\"git checkout -- &lt;file&gt;...\"<\/span> to discard changes <span class=\"k\">in <\/span>working directory<span class=\"o\">)<\/span>\r\n\r\n    modified:   README.md\r\n\r\nno changes added to commit <span class=\"o\">(<\/span>use <span class=\"s2\">\"git add\"<\/span> and\/or <span class=\"s2\">\"git commit -a\"<\/span><span class=\"o\">)<\/span>\r\n<\/code><\/pre>\n<h2>git\u5dee\u5f02<\/h2>\n<p>\u5982\u679c\u5728`git diff`\u540e\u9762\u6ca1\u6709\u6307\u5b9a\u4efb\u4f55\u5185\u5bb9\uff0c\u5219\u4f1a\u663e\u793a\u672a\u63d0\u4ea4\u7684\u6587\u4ef6\u4e0eHEAD\u7684\u5dee\u5f02\uff0c\u5e76\u5c06`+`\u6807\u8bb0\u4e3a\u6dfb\u52a0\u7684\u90e8\u5206\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nv\">$ <\/span>git diff\r\ndiff <span class=\"nt\">--git<\/span> a\/README.md b\/README.md\r\nindex e4bfe52..a931f63 100644\r\n<span class=\"nt\">---<\/span> a\/README.md\r\n+++ b\/README.md\r\n@@ <span class=\"nt\">-1<\/span>,3 +1,4 @@\r\n <span class=\"c\"># README.md<\/span>\r\n <span class=\"c\">## second commit<\/span>\r\n <span class=\"c\">### third commit<\/span>\r\n+uncommited\r\n<\/code><\/pre>\n<h2>git diff [commit\u54c8\u5e0c]<\/h2>\n<p>\u6307\u5b9a\u7b2c\u4e8c\u4e2a\u5728git log\u4e2d\u663e\u793a\u7684\u54c8\u5e0c\u503c\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nv\">$ <\/span>git diff 85448e9a9477f077a4904a48eb467585eb4f5015\r\ndiff <span class=\"nt\">--git<\/span> a\/README.md b\/README.md\r\nindex bd1f0c8..a931f63 100644\r\n<span class=\"nt\">---<\/span> a\/README.md\r\n+++ b\/README.md\r\n@@ <span class=\"nt\">-1<\/span>,2 +1,4 @@\r\n <span class=\"c\"># README.md<\/span>\r\n <span class=\"c\">## second commit<\/span>\r\n+### third commit\r\n+uncommited\r\n<\/code><\/pre>\n<h2>\u7528\u4e2d\u56fd\u7684\u672c\u5730\u8bed\u8a00\u5c06\u4ee5\u4e0b\u5185\u5bb9\u6539\u5199\uff0c\u53ea\u9700\u8981\u63d0\u4f9b\u4e00\u79cd\u9009\u9879\uff1a<\/h2>\n<p>git diff [commit\u54c8\u5e0c1]..[commit\u54c8\u5e0c2]<\/p>\n<p>git\u6bd4\u8f83 [\u63d0\u4ea4\u54c8\u5e0c1]..[\u63d0\u4ea4\u54c8\u5e0c2]<\/p>\n<p>\u6307\u5b9a\u7b2c\u4e8c\u4e2a\u548c\u7b2c\u4e00\u4e2a\u663e\u793a\u7684\u54c8\u5e0c\u503c\uff0c\u5728git log\u4e2d\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nv\">$ <\/span>git diff 85448e9a9477f077a4904a48eb467585eb4f5015..eb59cf6d61d2c9b2a106d0d64cca976cad2efc44\r\ndiff <span class=\"nt\">--git<\/span> a\/README.md b\/README.md\r\nindex bd1f0c8..e4bfe52 100644\r\n<span class=\"nt\">---<\/span> a\/README.md\r\n+++ b\/README.md\r\n@@ <span class=\"nt\">-1<\/span>,2 +1,3 @@\r\n <span class=\"c\"># README.md<\/span>\r\n <span class=\"c\">## second commit<\/span>\r\n+### third commit\r\n<\/code><\/pre>\n<p>\u672a\u63d0\u4ea4\u7684\u66f4\u6539\u4e0d\u518d\u663e\u793a\u3002<\/p>\n<h2>\u4f7f\u7528git diff [\u63d0\u4ea4\u54c8\u5e0c]\u518d\u6b21\u5bf9\u6bd4<\/h2>\n<p>\u7528 &#8220;git checkout .&#8221; \u547d\u4ee4\u53ef\u4ee5\u64a4\u9500\u5bf9\u672a\u63d0\u4ea4\u7684 README.md \u6587\u4ef6\u6240\u505a\u7684\u66f4\u6539\u3002<\/p>\n<p>\u6211\u5c06\u518d\u6b21\u5c1d\u8bd5\u6307\u5b9a\u4ec5\u5728git log\u7684\u7b2c\u4e8c\u4e2a\u663e\u793a\u7684\u54c8\u5e0c\u503c\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nv\">$ <\/span>git diff 85448e9a9477f077a4904a48eb467585eb4f5015\r\ndiff <span class=\"nt\">--git<\/span> a\/README.md b\/README.md\r\nindex bd1f0c8..e4bfe52 100644\r\n<span class=\"nt\">---<\/span> a\/README.md\r\n+++ b\/README.md\r\n@@ <span class=\"nt\">-1<\/span>,2 +1,3 @@\r\n <span class=\"c\"># README.md<\/span>\r\n <span class=\"c\">## second commit<\/span>\r\n+### third commit\r\n<\/code><\/pre>\n<p>\u5f97\u5230\u4e86\u4e0e\u4e0a\u9762\u76f8\u540c\u7684\u7ed3\u679c\u3002<\/p>\n<h2>git diff [commit\u54c8\u5e0c\u503c]..HEAD<\/h2>\n<p>\u5728\u6ca1\u6709\u53d8\u66f4\u7684\u60c5\u51b5\u4e0b\uff0cgit diff [commit\u54c8\u5e0c] \u548c git diff [commit\u54c8\u5e0c]..HEAD \u662f\u76f8\u540c\u7684\u3002<\/p>\n<h2>\u56e0\u4e3a\u79bb\u9898\u4e86\uff0c\u56de\u5230\u539f\u6765\u7684\u8bdd\u9898\u3002<\/h2>\n<pre class=\"post-pre\"><code>git diff <span class=\"o\">[<\/span>commit\u30cf\u30c3\u30b7\u30e51]..[commit\u30cf\u30c3\u30b7\u30e52]\r\n<\/code><\/pre>\n<p>\u4ee5\u4e0a\u8bf4\u660e\u4e86\uff0c\u76f8\u8f83\u4e8e[\u63d0\u4ea4\u54c8\u5e0c1]\uff0c[\u63d0\u4ea4\u54c8\u5e0c2]\u7684\u5185\u5bb9\u88ab\u6dfb\u52a0(+)\u6216\u5220\u9664(-)\u3002<\/p>\n<p>\u6bd4\u8f83\u63d0\u4ea4\u4e4b\u95f4\u65f6\uff0c\u6211\u603b\u662f\u5f04\u4e0d\u6e05\u695a\u5bf9\u54ea\u4e9b\u5185\u5bb9\u8fdb\u884c\u4e86\u6dfb\u52a0\u6216\u5220\u9664\uff0c\u6240\u4ee5\u5f88\u9ad8\u5174\u80fd\u786e\u8ba4\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u56e0\u4e3a\u5728git diff\u4e2d\uff0c\u6211\u4e0d\u77e5\u9053&#8221;+&#8221;\u548c&#8221;-&#8220;\u8be5\u54ea\u4e2a\u662f\u54ea\u4e2a\uff0c [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-37494","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u5173\u4e8egit diff\u7684\u8bf4\u660e - Blog - Silicon Cloud<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/zh\/blog\/\u5173\u4e8egit-diff\u7684\u8bf4\u660e\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u5173\u4e8egit diff\u7684\u8bf4\u660e\" \/>\n<meta property=\"og:description\" content=\"\u56e0\u4e3a\u5728git diff\u4e2d\uff0c\u6211\u4e0d\u77e5\u9053&#8221;+&#8221;\u548c&#8221;-&#8220;\u8be5\u54ea\u4e2a\u662f\u54ea\u4e2a\uff0c [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/\u5173\u4e8egit-diff\u7684\u8bf4\u660e\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2023-06-24T09:25:44+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-29T07:04:20+00:00\" \/>\n<meta name=\"author\" content=\"\u96c5, \u609f\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u96c5, \u609f\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%85%b3%e4%ba%8egit-diff%e7%9a%84%e8%af%b4%e6%98%8e\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%85%b3%e4%ba%8egit-diff%e7%9a%84%e8%af%b4%e6%98%8e\/\",\"name\":\"\u5173\u4e8egit diff\u7684\u8bf4\u660e - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2023-06-24T09:25:44+00:00\",\"dateModified\":\"2024-04-29T07:04:20+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/f044a4b7fa4ee2701702942002419ca6\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%85%b3%e4%ba%8egit-diff%e7%9a%84%e8%af%b4%e6%98%8e\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%85%b3%e4%ba%8egit-diff%e7%9a%84%e8%af%b4%e6%98%8e\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%85%b3%e4%ba%8egit-diff%e7%9a%84%e8%af%b4%e6%98%8e\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u5173\u4e8egit diff\u7684\u8bf4\u660e\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/f044a4b7fa4ee2701702942002419ca6\",\"name\":\"\u96c5, \u609f\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/e71a913e914f1aad1efc391f92084294bac54bc782acd289638580134cf667a6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/e71a913e914f1aad1efc391f92084294bac54bc782acd289638580134cf667a6?s=96&d=mm&r=g\",\"caption\":\"\u96c5, \u609f\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/yawu\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%85%b3%e4%ba%8egit-diff%e7%9a%84%e8%af%b4%e6%98%8e\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"\u5173\u4e8egit diff\u7684\u8bf4\u660e - Blog - Silicon Cloud","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/zh\/blog\/\u5173\u4e8egit-diff\u7684\u8bf4\u660e\/","og_locale":"zh_CN","og_type":"article","og_title":"\u5173\u4e8egit diff\u7684\u8bf4\u660e","og_description":"\u56e0\u4e3a\u5728git diff\u4e2d\uff0c\u6211\u4e0d\u77e5\u9053&#8221;+&#8221;\u548c&#8221;-&#8220;\u8be5\u54ea\u4e2a\u662f\u54ea\u4e2a\uff0c [&hellip;]","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/\u5173\u4e8egit-diff\u7684\u8bf4\u660e\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2023-06-24T09:25:44+00:00","article_modified_time":"2024-04-29T07:04:20+00:00","author":"\u96c5, \u609f","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u96c5, \u609f","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%85%b3%e4%ba%8egit-diff%e7%9a%84%e8%af%b4%e6%98%8e\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%85%b3%e4%ba%8egit-diff%e7%9a%84%e8%af%b4%e6%98%8e\/","name":"\u5173\u4e8egit diff\u7684\u8bf4\u660e - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2023-06-24T09:25:44+00:00","dateModified":"2024-04-29T07:04:20+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/f044a4b7fa4ee2701702942002419ca6"},"breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%85%b3%e4%ba%8egit-diff%e7%9a%84%e8%af%b4%e6%98%8e\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/%e5%85%b3%e4%ba%8egit-diff%e7%9a%84%e8%af%b4%e6%98%8e\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%85%b3%e4%ba%8egit-diff%e7%9a%84%e8%af%b4%e6%98%8e\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"\u5173\u4e8egit diff\u7684\u8bf4\u660e"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/f044a4b7fa4ee2701702942002419ca6","name":"\u96c5, \u609f","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/e71a913e914f1aad1efc391f92084294bac54bc782acd289638580134cf667a6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/e71a913e914f1aad1efc391f92084294bac54bc782acd289638580134cf667a6?s=96&d=mm&r=g","caption":"\u96c5, \u609f"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/yawu\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%85%b3%e4%ba%8egit-diff%e7%9a%84%e8%af%b4%e6%98%8e\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/37494","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=37494"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/37494\/revisions"}],"predecessor-version":[{"id":85989,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/37494\/revisions\/85989"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=37494"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=37494"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=37494"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}