File detected as binary, not displayed as text in Bitbucket

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

目的

Bitbucket will display the contents of all plain text files when git detects them as not binary.  If you have a file that should display in Bitbucket and it does not, this can sometimes happen when git looks in the first few bytes of the file for null characters or non ascii characters.  When this happens Bitbucket Server will not display the file and will offer a download link instead.  You can confirm if this is the case by using vi or hexdump.  Here is an example:

Text File:

$ hexdump text.xml
0000000 3c 70 72 6f 70 65 72 74 69 65 73 3e 3c 2f 70 72
0000010 6f 70 65 72 74 69 65 73 3e 0a
000001a

This file will be detected as binary:

$ hexdump bin.xml
0000000 00 3c 70 72 6f 70 65 72 74 69 65 73 3e 3c 2f 70
0000010 72 6f 70 65 72 74 69 65 73 3e 0a
000001b

cat will not show this blank byte at the start of the file:

$ cat bin.xml
<properties></properties>

vi will show it like this:

^@<properties></properties>


ソリューション

  • Delete the characters in the file with vi that causes git to report it as binary.
  • Push the updated file to Bitbucket Server in a new commit.
  • Confirm the file can be viewed as text not binary in Bitbucket.

 

最終更新日 2017 年 4 月 18 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.