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

Viewed 1202

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

2 Answers

You can do (recent git only!)

*.ps1 text working-tree-encoding=UTF-16LE eol=CRLF

(Remove the LE if with bom etc)

This goes in your gitattributes file

Related