CRLF, LF

강혜성·2023년 3월 22일
0

분산처리

목록 보기
12/18

Git CRLF / LF

  • CRLF/LF는 OS에 따라 다른 개행 방식이다. 리눅스와 맥같은 Unix-like System은 LF 방식을 사용하고, 윈도우는 CR/LF 방식을 사용

  • lf 방식을 사용하기로 함

1. .gitattributes 파일 생성

  • gitattributes 파일을 생성해서 lf 방식으로 변경
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto

# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.
*.c text
*.h text

# Declare files that will always have LF line endings on checkout.
*.sln text eol=lf

# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary
.*	text eol=lf
*.css	text eol=lf
*.html	text eol=lf
*.jade	text eol=lf
*.js	text eol=lf
*.json	text eol=lf
*.less	text eol=lf
*.scss	text eol=lf
*.md	text eol=lf
*.sh	text eol=lf
*.txt	text eol=lf
*.xml	text eol=lf
*.ts	text eol=lf
*.java	text eol=lf	
*.class	text eol=lf
  • 위와 같이 설정해두면 CRLF로 작성한 파일을 Git에 올린후 다시 Clone 받으면 lf로 뜨는걸 확인할 수 있다.

2. IntteliJ LF 적용

  • 기본 설정 확인을 위해서 에디터 라인분리자 확인
  • [File] - [Settings] - [Editor] - [Code Style] - [Line Seperator]
  • System-Dependent로 설정되어 있다.
  • Unix and macOS (\n)으로 변경

0개의 댓글