[Github] Github Newline + IntelliJ์์ ์ต์ ์ค์
Github์์์ ์ค๋ฅ
: no newline at a end of file
ํ์ผ ์คํ ๋ฑ์๋ ๋ฌธ์ ๊ฐ ์๋๋ฐ ์ ์ด๋ฐ ์ค๋ฅ๋ฅผ ํ์ํด์ฃผ๋ ๊ฒ์ผ๊น?
: POSIX๋ฅผ ๋ง์กฑ์ํค๊ธฐ ์ํด์
POSIX์์ ๋ฌธ์ ๊ฐ ๋๋ ์ด์ ?
POSIX(Portable Operating System Interface) ํ์ค์ ๋ฐ๋ฅด๋ฉด:
"A text file shall end with a newline character."
์ฆ, POSIX์์ ํ ์คํธ ํ์ผ์ ๋ง์ง๋ง ์ค๋ ์ค๋ฐ๊ฟ์ผ๋ก ๋๋์ผ ํ๋ค๋ ๋ช ํํ ๊ท์น์ด ์์
- ํ์ดํ/๋ฆฌ๋ค์ด๋ ์
์ฒ๋ฆฌ ๋ฌธ์
- POSIX ํ๊ฒฝ์์๋ ์ ๋์ค ์ฒ ํ์ ๋ฐ๋ผ ์ฌ๋ฌ ๋ช ๋ น์ด๋ฅผ ํ์ดํ๋ก ์ฐ๊ฒฐํด์ ์ฒ๋ฆฌํ๋ ๊ฒฝ์ฐ๊ฐ ๋ง์.
- ์ด๋ ์ค ๋จ์๋ก ์ ๋ ฅ์ ๋ฐ๋๋ฐ ๋ง์ง๋ง ์ค์ newline์ด ์์ผ๋ฉด ๋ง์ง๋ง ์ค์ด "์์ ํ ํ ์ค"๋ก ์ธ์๋์ง ์์ ์ ์์.
- diff/patch ์ ์ฉ ์ค๋ฅ ๊ฐ๋ฅ์ฑ
- diff/patch ์ ํธ๋ฆฌํฐ๋ POSIX ๊ธฐ๋ฐ์ผ๋ก ๋์ํ๋ฉฐ ์ค ๋จ์๋ก ํจ์น๋ฅผ ์์ฑ/์ ์ฉ.
- newline์ด ์์ผ๋ฉด ํจ์น ์ ์ฉ ์ ์ค๋ฅ ๋๋ ์๊ธฐ์น ์์ ๊ฒฐ๊ณผ ๋ฐ์ ๊ฐ๋ฅ์ฑ ์์.
- ์ ๋ ฌ·ํ์ฑ ํด๋ค ๋์ ๋ถ์์
- sort, awk, sed ๋ฑ POSIX ๋๊ตฌ๋ค์ด "ํ ์ค์ด ์ค๋ฐ๊ฟ์ผ๋ก ๋๋๋ค"๋ ์ ์ ๋ฅผ ๊ฐ์ง๊ณ ์์.
ํด๊ฒฐ ๋ฐฉ๋ฒ
1. IntelliJ ์ค์ ์ผ๋ก ํด๊ฒฐํ๊ธฐ
Settings
> General
> On Save
์ผ๋ก ์ด๋ํด์
Ensure every saved file ends with a line break์ ์ฒดํฌ ํ์๋ฅผ ํ๋ฉด ๋๋ค.
2. .editorconfig
ํ์ผ ์ด์ฉ
.editorconfig
: ์ฝ๋๋ฒ ์ด์ค์์ ์๋ํ๋ ๋ชจ๋ ์ฌ์ฉ์์๊ฒ ์ผ๊ด๋ ์ฝ๋ฉ ์คํ์ผ์ ์ ์ฉ ๊ฐ๋ฅํ๊ฒ ํ๋ ํ์ผ
- IDE์์์ ์ค์ ๋ณด๋ค editorconfig ํ์ผ์ด ์ฐ์ ๋จ
- ๋ฃจํธ ๊ฒฝ๋ก์ ๋ฃ์ผ๋ฉด ์ฝ๋ ์์ฑ ์ ์ ์ฉ๋จ
root = true
[*]
# [encoding-utf8]
charset = utf-8
# [newline-lf]
end_of_line = lf
# [newline-eof]
insert_final_newline = true
[*.bat]
end_of_line = crlf
[*.java]
# [indentation-tab]
indent_style = tab
# [4-spaces-tab]
indent_size = 4
tab_width = 4
# [no-trailing-spaces]
trim_trailing_whitespace = true
[line-length-120]
max_line_length = 120
EditorConfig
What is EditorConfig? EditorConfig helps maintain consistent coding styles for multiple developers working on the same project across various editors and IDEs. The EditorConfig project consists of a file format for defining coding styles and a collection o
editorconfig.org