Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GIT checkout shows files in a wrong encoding

The question might be quite dumb in the end, but...

I have a local GIT repo in a Win 7 environment, working with GIT in Windows command line. All the files are in UTF-8 (no BOM), texts contain non-ASCII symbols (German, Russian, etc...), so do commit messages. At some moment I needed to recall some data from past commits, which is in non-ASCII symbols. But both gitk and git checkout <commit-hash> show the files in non-UTF-8 encoding (default ANSI according to Notepad++), of course breaking UTF-8-only symbols. Cheking out back to HEAD restores files' encoding.

Am I missing something? Maybe some GIT settings need to be made. My guess is that git files are non-UTF-8 and thus can't have such symbols.

I also have to mention non-ASCII commit messages work fine (git log and gitk show them properly although I didn't change the cmd endoding).

Thanks!


Edit: here is what the my files look like in gitk or when checked out (notice the characters in the comment line):

@import 'reset';
@import 'mixins';
@import 'animations';
@import 'variables';
@import 'helpers';

/* ==================== Шрифты ==================== */
@font-face{
    font-family:'ClearSans';
    src:url('../fonts/ClearSans-Medium.eot');
    src:url('../fonts/ClearSans-Medium.eot?#iefix') format('embedded-opentype'),
         url('../fonts/ClearSans-Medium.woff') format('woff'),
         url('../fonts/ClearSans-Medium.ttf') format('truetype'),
         url('../fonts/ClearSans-Medium.svg') format('svg');
    font-weight:normal;
    font-style:normal;
}
like image 606
bonflash Avatar asked Sep 13 '14 05:09

bonflash


1 Answers

If git checkout HEAD fixes the files, it means they were corrupted in old commits and then fixed. Git itself doesn't care about encodings and tracks any file equally well, it only looks at line endings.

like image 80
Sergey Kuznetsov Avatar answered Sep 20 '22 06:09

Sergey Kuznetsov