git,

Resolve 'No newline at end of line' in GitHub

Apr 29, 2023 · 1 min read · Post a comment

Creating the first Pull Request could be anxious, you feel like being judged by other engineers. Generally, the first thing you might notice is the GitHub red sign saying “No newline at the end of line”. Mostly this issue occurs on Windows machines though. However, here’s how to deal with it.

Prerequisites

  • Git

Solution(s)

Solution #1. First thing to try, is to add a newline, duh. This can be configured in the VSCode. Go to Settings -> Search for newline and enable the option named: Files: Insert Final Newline. This will enable automatically insert a new final empty line.

Solution #2. If that doesn’t work, make sure to have the EOF Mark VSCode Plugin installed. Double check files w/o the EOF mark.

Solution #3. In the bottom VSCode bar, check for any LF or CRLF end of line sequence. Play around with it.

Step 4. Last but not least, configure Git to handle line endings:

git config --global core.autocrlf input

Conclusion

In case you face any issues, feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.