Search code examples
gitpowershellatlassian-sourcetree

Why does Source Tree not Git Diff a Powershell Script (ps1)


I'm using SourceTree as my git client on Windows (v1.8.3.0). For some reason it's not showing a diff of my PowerShell script (.ps1) and instead shows it as a binary:

enter image description here

Is there a setting I need to toggle to get correct behavior? If I rename the file to be a .txt than the diff works as expected.

I have a .gitattributes file in my repo, and I've updated it to explicitly account for .ps1 files, but that doesn't seem to work either:

*.ps1   diff=astextplain
*.PS1   diff=astextplain

Alternatively, I can see the diff just fine in I goto External Diff (via BeyondCompare), however, this doesn't help me craft a commit based of specific line numbers:

enter image description here


Solution

  • It looks like this is a known issue with Atlassian products (BitBucket, SourceTree): https://bitbucket.org/site/master/issues/5453/powershell-module-manifest-file-psd1-are

    The issue is my .ps1 file was saved as UTF16 Unicode. Changing it to UTF8 or ascii fixes this and I get diffs inside of SourceTree again.