Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 948
Philip Pittle Avatar asked Dec 12 '25 03:12

Philip Pittle


1 Answers

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.

like image 57
Philip Pittle Avatar answered Dec 13 '25 16:12

Philip Pittle



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!