Skip to content

Commit

Permalink
Make git diff works on UTF-16 file
Browse files Browse the repository at this point in the history
  • Loading branch information
keineahnung2345 authored Sep 12, 2024
1 parent 7f383ce commit 1b3c579
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Git commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -1204,3 +1204,21 @@ git checkout master
```sh
git config core.protectNTFS false
```

## Make git diff works on UTF-16 file

[Diff .strings files in Git](https://blog.xk72.com/post/31456986659/diff-strings-files-in-git)

[Can I make git recognize a UTF-16 file as text?](https://stackoverflow.com/questions/777949/can-i-make-git-recognize-a-utf-16-file-as-text)

`.gitattributes`中:

```
*.<file_extension> diff=utf16 eof=crlf
```

`.git/config`中加入:
```
[diff "utf16"]
textconv = "iconv -f UTF-16LE -t UTF-8"
```

0 comments on commit 1b3c579

Please sign in to comment.