0

When I push commits to Bitbucket and create pull-request, I can see in a diff a weird symbol (\ufeff) is added to the start of newly created files.

I don't want GitKraken to add any additional symbols, so the commits would have been pure. How to achieve that?

iOne
  • 153
  • 2
  • 12
  • What editor are you using to edit the files? That's likely the cause of your issue. – bk2204 May 20 '19 at 23:27
  • @bk2204, I use Visual Studio 2017 Enterprise. Before GitKraken I used SourceTree and after I switched from SourceTree to GitKraken the issue has appeared. So I don't think the problem is caused by editor. – iOne May 22 '19 at 09:43

2 Answers2

3

By default, when Visual Studio writes a file, either in UTF-16 or UTF-8, it writes a byte order mark (BOM, U+FEFF) to the beginning of the file. This mark is required when using UTF-16, but it's widely considered a bad idea to write it in files with UTF-8.

Normally, a byte order mark is zero-width, so the likely reason you're seeing it in GitKraken and not SourceTree is because GitKraken explicitly shows it, whereas SourceTree probably does not.

If you're saving files as UTF-8 in Visual Studio, you need to save them manually as "UTF-8 without signature". If you save them using the default mode, it saves them with a BOM.

Alternatively, you can add an .editorconfig file to your project which sets the default character set as utf-8. That will direct Visual Studio not to write a BOM in your files. If your project is reticent to adopt such a file, you can create one yourself and ignore it by adding .editorconfig to its own line in .git/info/exclude.

bk2204
  • 64,793
  • 6
  • 84
  • 100
0

On a recent git adding the following to .gitattributes should solve your problem :

 *.cpp text working-tree-encoding=UTF-8 eol=CRLF

Replace cpp by whatever file type you need

Note: See the .gitattributes man page

  • for your as well as all your coworkers' gits (they should all support)
  • also check the iconv call working given there
Rusi
  • 1,054
  • 10
  • 21