Diff for Latin1-encoded files

I'm using both Latin1 and UTF8 encoded files in my projects. The browser showing diffs seems always to assume the UTF8 encoding, resulting in incorrectly showing non-ascii characters. Is there a way to tell SourceTree (or Git) about the encoding of a file?

Addendum: picking an encoding on a per-project basis would be sufficient rather than on a per-file basis. The reason I'm using Latin1 in some projects is that these are legal documents that I share with non-developers on Windows machines that seem to prefer it.

2 answers

1 accepted

1 vote
Accepted answer

Actually, I take it back, there is a way to do this. You can create a .gitattributes file for the folder/pattern and define the 'encoding' setting there. This should be picked up by SourceTree in the diffs too. http://schacon.github.com/git/gitattributes.html

No. There's no practical reason to be using Latin1 encoding in 2012. While you can change the encoding in git, doing it on a per-file basis is very impractical. You'll save ourself far more pain just by standardising on UTF.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Oct 23, 2018 in Sourcetree

Tip from the team: configure your repos for hosting goodness!

Supported Platforms macOS Windows We recently introduced support for additional hosting services such as GitHub Enterprise, GitLab (Cloud, Community Edition, Enterprise Edition), and...

727 views 3 2
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you