리눅스 diff3

1 개요[ | ]

diff3
/usr/bin/diff3
  • 파일 3개를 비교하는 리눅스 명령어
  • 세 파일의 차이를 보여줌

2 예시[ | ]

$ tail -n99 *.yaml
==> base.yaml <==
image: nginx:1.29
replicas: 1

==> local.yaml <==
image: nginx:1.30
replicas: 1

==> remote.yaml <==
image: nginx:1.29
replicas: 2
$ diff3 local.yaml base.yaml remote.yaml
====
1:1,2c
  image: nginx:1.30
  replicas: 1
2:1,2c
  image: nginx:1.29
  replicas: 1
3:1,2c
  image: nginx:1.29
  replicas: 2
→ 기본 실행은 둘씩 diff를 차례로 보여준다.
$ diff3 -m local.yaml base.yaml remote.yaml
<<<<<<< local.yaml
image: nginx:1.30
replicas: 1
||||||| base.yaml
image: nginx:1.29
replicas: 1
=======
image: nginx:1.29
replicas: 2
>>>>>>> remote.yaml
-m 옵션을 주면 자동 병합 결과를 출력하는데, 충돌 구간은 local, base, remote 내용을 모두 표시한다.
$ diff3 -mE local.yaml base.yaml remote.yaml
<<<<<<< local.yaml
image: nginx:1.30
replicas: 1
=======
image: nginx:1.29
replicas: 2
>>>>>>> remote.yaml
-mE 옵션을 주면 자동 병합 결과를 출력하는데, base 내용은 생략되고 local과 remote의 차이만 표시된다. Git에서 충돌(conflict) 상황을 보여줄 때와 유사한 형식이다.

3 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}