Changes to a PowerShell Module Manifest not viewable in Git

When you make a change to a PowerShell Module Manifest and go to commit those changes in Git, I have observed for some time that it was not possible to see the actual changes in the file because Git was showing it as a binary file. I finally found out why this happens……

Take the following example. I’ve created a module manifest for a module Test with New-ModuleManifest:

Now I make a change to the manifest, say up the version to 1.1

When I go to commit the file, I don’t see what has actually changed in the file. Git reports that it is a binary file:

This is because the output from New-ModuleManifest uses UTF16 for encoding, hence Git sees it as a binary file.

Using the handy encoding functions from here we can check the encoding for the manifest file:

I learnt this from the regular PowerShell community call  where there was a discussion around standardising on the encoding for all cmdlets in PowerShell Core 6. In versions prior to 6 different cmdlets use different encodings types, so it seems like a good opportunity to standardise, particularly with the move to make PowerShell cross-platform and Linux having a default encoding of UTF8. There is a lot more information here on the proposal for PowerShell Core and encoding going forward.

So, let’s change the encoding of the manifest file to UTF8:

Now let’s change the manifest file again and see if we can view the changes in Git:



Or in VS Code:

Happy Days 🙂

Thanks to Joey Aiello for sharing this on today’s community call.


2 thoughts on “Changes to a PowerShell Module Manifest not viewable in Git

  1. I suspect this is a limitation of the GUI tool being used for Git.

    test> git init
    Initialized empty Git repository in C:/git/test/.git/
    test [master]> New-ModuleManifest -Path Test.psd1
    test [master +1 ~0 -0 !]> git add . ; git commit -m “test”
    [master (root-commit) 8f9bec6] test
    1 file changed, 0 insertions(+), 0 deletions(-)
    create mode 100644 Test.psd1
    test [master]> Add-Content .\Test.psd1 “# Test”
    test [master +0 ~1 -0 !]>

    The command line tools have no issues seeing the new manifest or changes to it.

Comments are closed.