Why not login to Qiita and try out its useful features?

We'll deliver articles that match you.

You can read useful information later.

2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Git】末尾に改行があるべき!? \ No newline at end of fileの意味とその対応方法!

2
Posted at

概要

  • git diffで差分を確認したところ、\ No newline at end of fileというエラーが表示されました。何も変えていないファイルなのになぜ?と思い、調べてみました。
\ No newline at end of file

原因・解決方法

POSIX的にはテキストファイル末尾には改行があるべきらしく、vimでテキストファイルを開いて保存すると改行が付く。

混乱のもとは、ファイル末尾に改行を付与するエディタ(vim)とファイル末尾に改行を付与しないエディタ(他のエディタ)混在しているからかと思われる。

  • 改行を入れてあげれば解決できますが、毎回行うのが面倒な場合は、vim でファイルを開き、コマンドモードで下記を実行して保存すれば、警告がなくなります。
:set binary noeol
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up

@Ryo-0131's pickup articles

Ryo-0131

@Ryo-0131(Citrus Tech)

"記憶よりも記録"をモットーにしたエンジニアリング日誌。読み返したら甘酸っぱいものである🍊 基本的にポエム系は書きません。100週連続投稿バッジ達成☆ Python(Django)/AWS/Docker/Ruby on Rails/Wordpress

Comments

No comments

Let's comment your feelings that are more than good

Being held Article posting campaign

2025年、生成AIを使ってみてどうだった?

2026-01-19 ~ 2026-02-27

View details
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Login to continue?

Login or Sign up with social account

Login or Sign up with your email address