0

I'm using Git as my DVCS with GitHub Desktop as my gui. I'm trying to view the diff of commits of my PS script via GitHub but it treats it as a binary.

From this question, I have included a .gitattribute file to the root of the repo to diff .ps1 files, *.ps1 diff. However, because .ps1 files are UTF-16, it is unsuccessful and doesn't actually diff anything. Is there a way to encode PS files in UTF-8 or are there any other workarounds to this issue?

charwayne
  • 103
  • 1
  • 3
  • 18
  • `.ps1` scripts should be UTF8 or UTF8 w/ BOM. If you're running into Unicode (UTF16), you should convert them. – Maximilian Burszley Dec 08 '17 at 20:45
  • If you're using VSCode, you can click on the file encoding in the bottom right and then choose "Save With Encoding" and select the proper one(s). – Maximilian Burszley Dec 08 '17 at 20:46
  • @TheIncorrigible1 I'm running this from the PowerShell ISE included with Windows. Any reason why that would be any different? – charwayne Dec 08 '17 at 20:58
  • 1
    It should be saving files with UTF8 encoding and I haven't observed it behaving any different (except when creating `.psd1` files with `New-ModuleManifest` being UTF16LE). I would suggest migrating to VSCode with the PS extension as that's Microsoft's stated direction for PowerShell script editing. – Maximilian Burszley Dec 08 '17 at 21:11
  • @TheIncorrigible1 I moved to VSCode and can confirm the previous version was in UTF16, I have since converted to UTF8 and diff works great now! Thanks for the help. – charwayne Dec 11 '17 at 18:47

0 Answers0