{"id":875,"date":"2013-06-26T13:18:13","date_gmt":"2013-06-26T18:18:13","guid":{"rendered":"http:\/\/trillworks.com\/nick\/?p=875"},"modified":"2013-06-26T13:18:13","modified_gmt":"2013-06-26T18:18:13","slug":"git-diff-with-full-context","status":"publish","type":"post","link":"https:\/\/trillworks.com\/nick\/2013\/06\/26\/git-diff-with-full-context\/","title":{"rendered":"git diff with full context"},"content":{"rendered":"<p>By default, git diff only spits out three lines of context above and below your changes. However, it&#8217;s possible to include the entire file. Generate a patch of some changes with full context:<\/p>\n<pre>git diff --no-prefix -U1000 &gt; \/tmp\/mydiff.patch<\/pre>\n<p>If you&#8217;ve already committed your changes, you can use git show with the same syntax:<\/p>\n<pre>git show --no-prefix -U1000 &gt; \/tmp\/mydiff.patch<\/pre>\n<p>These are useful for pre-commit code reviews in Crucible. You can just upload the resulting patch file.<\/p>\n<p>The &#8211;no-prefix option gets rid of the &#8220;\/a\/&#8221; and &#8220;\/b\/&#8221; destination prefixes that show up by default.<\/p>\n<p>The -U flag specifies lines of context. You might need to increase this if there are more than 1000 lines between your changes.<\/p>\n<p>If you don&#8217;t want to type all that out, add an alias in your ~\/.gitconfig file.<\/p>\n<pre>[alias]\r\n code-review = diff -p --no-prefix -U1000<\/pre>\n<p>Then you can just do:<\/p>\n<pre>git code-review &gt; \/tmp\/mydiff.patch<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>By default, git diff only spits out three lines of context above and below your changes. However, it&#8217;s possible to include the entire file. Generate a patch of some changes with full context: git diff &#8211;no-prefix -U1000 &gt; \/tmp\/mydiff.patch If you&#8217;ve already committed your changes, you can use git show with the same syntax: git &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/trillworks.com\/nick\/2013\/06\/26\/git-diff-with-full-context\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;git diff with full context&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[77],"tags":[],"class_list":["post-875","post","type-post","status-publish","format-standard","hentry","category-technical"],"_links":{"self":[{"href":"https:\/\/trillworks.com\/nick\/wp-json\/wp\/v2\/posts\/875","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/trillworks.com\/nick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/trillworks.com\/nick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/trillworks.com\/nick\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/trillworks.com\/nick\/wp-json\/wp\/v2\/comments?post=875"}],"version-history":[{"count":3,"href":"https:\/\/trillworks.com\/nick\/wp-json\/wp\/v2\/posts\/875\/revisions"}],"predecessor-version":[{"id":878,"href":"https:\/\/trillworks.com\/nick\/wp-json\/wp\/v2\/posts\/875\/revisions\/878"}],"wp:attachment":[{"href":"https:\/\/trillworks.com\/nick\/wp-json\/wp\/v2\/media?parent=875"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/trillworks.com\/nick\/wp-json\/wp\/v2\/categories?post=875"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/trillworks.com\/nick\/wp-json\/wp\/v2\/tags?post=875"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}