5

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

7

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)? – maniac coder May 14 '17 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 May 15 '17 at 15:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.