From 5e70445b35577826414be31693d50d385b4f28cc Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Wed, 29 Jun 2016 22:50:59 -0500 Subject: [PATCH] Add Diffing With Patience as a git til --- README.md | 3 ++- git/diffing-with-patience.md | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 git/diffing-with-patience.md diff --git a/README.md b/README.md index 97c6511..3184f8f 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ variety of languages and technologies. These are things that don't really warrant a full blog post. These are mostly things I learn by pairing with smart people at [Hashrocket](http://hashrocket.com/). -_440 TILs and counting..._ +_441 TILs and counting..._ --- @@ -100,6 +100,7 @@ _440 TILs and counting..._ - [Clean Up Old Remote Tracking References](git/clean-up-old-remote-tracking-references.md) - [Delete All Untracked Files](git/delete-all-untracked-files.md) - [Determine The Hash Id For A Blob](git/determine-the-hash-id-for-a-blob.md) +- [Diffing With Patience](git/diffing-with-patience.md) - [Dry Runs in Git](git/dry-runs-in-git.md) - [Excluding Files Locally](git/excluding-files-locally.md) - [Find The Initial Commit](git/find-the-initial-commit.md) diff --git a/git/diffing-with-patience.md b/git/diffing-with-patience.md new file mode 100644 index 0000000..2bf2dbb --- /dev/null +++ b/git/diffing-with-patience.md @@ -0,0 +1,36 @@ +# Diffing With Patience + +The default diff algorithm used by Git is pretty good, but it can get +mislead by larger, complex changesets. The result is a noisier, misaligned +diff output. + +If you'd like a diff that is generally a bit cleaner and can afford a little +slow down (you probably can), you can instead use the `patience` algorithm +which is described as such: + +> Patience Diff, instead, focuses its energy on the low-frequency +> high-content lines which serve as markers or signatures of important +> content in the text. It is still an LCS-based diff at its core, but with +> an important difference, as it only considers the longest common +> subsequence of the signature lines: + +> Find all lines which occur exactly once on both sides, then do longest +> common subsequence on those lines, matching them up. + +You can set this as the default algorithm by adding the following lines to +your `~/.gitconfig` file: + +``` +[diff] + algorithm = patience +``` + +or it can be set from the command line with: + +```bash +$ git config --global diff.algorithm patience +``` + +[source](http://bryanpendleton.blogspot.com/2010/05/patience-diff.html) + +h/t Josh Davey