정의
git에서 diff 대신에 외부 도구를 이용하여 비교할 수 있게 해주는 명령어가 difftool임.
여러 tool이 있지만, vscode를 사용한다면 이를 지정할 수 있음
git diff: 현재 변경사항을 text 기반으로git difftool: 현재 변경사항을 외부도구로 보여줌.
설정
global로 사용하려면 다음의 명령어를 실행하여 설정 파일을 editor 로 연다 (기본 editor 로 열림)
git config --global -e
만약 vscode를 해당 설정을 편집하는 에디터로 사용하려면 다음을 참고:
2023.06.20 - [utils/git and github] - [Git] git 에서 editor 로 VS Code 사용하기.
[Git] git 에서 editor 로 VS Code 사용하기.
넋두리 Linux환경에서 가장 적응하기 귀찮은 게 무엇이냐라고 묻는다면...editor라고 말하고 싶다. 특히, 터치(?) 세대들은 gui에 익숙하다 보니 cli도 굉장히 부담스러워한다. vim은 꼭 익히길 권하지
ds31x.tistory.com
다음의 내용을 추가하고 저장하면 됨:
[diff]
tool = vscode
[difftool "vscode"]
cmd = code --wait --diff \"$LOCAL\" \"$REMOTE\"
[merge]
tool = vscode
[mergetool "vscode"]
cmd = code --wait \"$MERGED\"
jupyter notebook을 보다 편하게 보는 방법으로 nbdime을 이용하는 경우엔 다음을 추가한다.
(nbdime이 설치되어 있어야 함)
[difftool "nbdime-web"]
cmd = nbdiff-web \"$LOCAL\" \"$REMOTE\"
- 여기선
nbdiff-web을 이용함: 웹서버를 띄어 브라우저로 확인하는 것이라 끝내려면 CTRL+C와 같은 키보드인터럽트를 사용해야함. - 아니면 브라우저에서 보여지는 웹페이지에서 Close tool 을 클릭

이후 다음의 --tool옵션을 사용.
git difftool --tool=nbdime ./test.ipynb
git difftool의 다양한 option은 다음을 참조:
Options
--tool=<name>: 설정에 지정된 이름(앞서 설정에선vscode)으로 사용할 외부 도구를 지정.--no-prompt: 파일별 diff전 사용자 확인을 생략--dir-diff: 디렉토리 단위별로 비교
사용법
다음은 working tree와 stage의 차이를 비교:
git difftool
다음은 working tree와 마지막 commit의 차이를 비교:
git difftool HEAD
특정 commit간의 차이를 비교
git difftool commit1 commit2
특정 branch간의 차이를 비교
git difftool branch1 branch2
실제로 사용법은 git diff와 큰 차이는 없음
2024.05.20 - [utils/git and github] - [Git] git diff
[Git] git diff
git diffgit diff 명령어를 사용하면 어떤 라인이 추가되었는지, 삭제되었는지, 수정되었는지 등을 알 수 있음.Git에서 두 버전의 파일을 비교하여 차이를 보여주는 명령어변경된 내용이 어떤 것인지
ds31x.tistory.com
같이 보면 좋은 자료들
https://github.com/jupyter/nbdime
GitHub - jupyter/nbdime: Tools for diffing and merging of Jupyter notebooks.
Tools for diffing and merging of Jupyter notebooks. - jupyter/nbdime
github.com
2024.05.20 - [utils/git and github] - [Git] Git Summary (작성중)
[Git] Git Summary (작성중)
git이란2024.05.20 - [utils/git and github] - Git : 소개 git 설치 후 해줘야 하는 작업들[Git] git 설치 후 우선 해줘야 하는 작업들 (tistory.com)local repository 초기화2024.05.20 - [utils/git and github] - [Git] init : local repo
ds31x.tistory.com
'utils > git and github' 카테고리의 다른 글
| git init --bare : 편집가능한 소스 코드가 없는 (서버용) 저장소 만들기 (0) | 2025.12.01 |
|---|---|
| Relative Reference-Git-caret and tilde + Reflog Reference (1) | 2025.07.24 |
| SSH Agent 사용법 (2) | 2025.07.21 |
| 새로 remote 에 추가된 submodule 을 local 에 반영하기 (3) | 2025.07.11 |
| [git] How to Add a New Remote Branch to Your Local Repository (0) | 2024.12.26 |