Clear BOM before pushing files to the GitHub server
See original GitHub issueGreetings! I will try to explain the problem that has occurred in the headings of other issues without the text associated with the encoding of UTF-8.
Description
The source text in the markup files (MarkDown, html, etc.) is stored in UTF-8. When I save the text in Windows, BOM (0xEF, 0xBB, 0xBF) is added to the beginning of the file. (In Linux operating systems, files in the UTF-8 encoding are created without a BOM.) BOM stays when I pushed of data from the GitHub Desktop to the server, which can adversely affect the working of the source code. Usually to remove the BOM used third-party apps, such as Notepad++, which is not very convenient. Can GitHub Desktop delete from the BOM files when I push files to the Github server?
Version
GitHub Desktop version: 3.3.4.0
OS version: Microsoft Windows [Version 6.1.7601]
Steps to Reproduce
- I create a text file through Windows Explorer
- I type the text and save it in the encoding of UTF-8
- I change the file extension to MD
- Does not solve the problem
find . -type f \( -name '*.md' -o -name '*.html' \) -print0 | xargs -0 grep -l ``printf '^\xef\xbb\xbf'`` | xargs sed -i '1 s/^\xef\xbb\xbf//'
single ` - I push the changes to the server
Expected behavior: https://github.com/jekyll/minima/blame/a4726e60/index.md#L1
Actual behavior: https://github.com/bopoh13/grok/blame/7fb3be1f/index.md#L1
Reproduces how often: everytime
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
@bopoh13 I think this is a limitation of
notepad.exe
- I was able to reproduce this issue using the version of notepad that ships in Windows 10.This isn’t the right place to handle these changes - they need to be caught before committing, because after that the file contents (“blobs” in Git terminology) are tied to the created commit. You can’t change one without changing the other.
Git itself is not opinionated about the file contents which you add to the repository, and Desktop has no plans to warn about BOMs, so I’d recommend using tools like Notepad++ that you can trust to handle files in a cross-platform way.
✔️ The client hook must be placed on a local computer in the
REPO\.git\hooks
without extension.sh
. The rest will be done by the git himself. The issue is closed once and for all.