Sometimes when I look at changes to Salesforce metadata using a git diff tool like SourceTree it is not clear what's actually changed. If one block of XML has been deleted and another one inserted the diff tool will merge them together so that I see lots of insertion/deletion pairs. Is there a better way to see what's really changed? enter image description here

1 Answer 1


This answer is relevant to Salesforce metadata and also to anyone dealing with large blocks of XML or similar repetitive text. When working with large files in version control, especially large XML files like you get when working with Salesforce, the default behavior of git is sometimes not ideal. When one block of XML is removed and another one inserted, Git can sometimes merge those two together making the apparent changes hard to decipher. You can make a huge improvement to this behavior by changing your default git diff algorithm to one called "patience" by running this command on the command line.

git config --global diff.algorithm patience

This video illustrates that difference

Here's the diff after changing the algorithm Improved Diff using the patience algorithm

  • Will this work if I am using merge tools like Tortoise git or any other tool(not the native git tool)? Commented May 14, 2017 at 4:56
  • This will work for any tools that rely on Git's built-in diff behavior. That definitely includes SourceTree. I'm not sure about other Git graphical tools, but I would expect that most of them would rely on Git's diff.
    – abd3721
    Commented May 15, 2017 at 15:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .