[git] git 수정된 파일만 보기
git에서 다른 브랜치와 비교할 때 diff 명령어를 사용하면 변경된 내역을 볼 수 있다.
git diff를 사용하면 변경된 내역들 전체가 나오는데, 수정된 파일만 보고 싶다면 --diff-filter 옵션을 추가하면 된다.
> git diff --name-only --diff-filter=M main
(--name-only는 수정된 파일의 내용은 보지 않고 이름만 보기 위한 옵션이다.)
총 3개의 파일이 추가 또는 수정된 상황에서 필터 옵션을 사용하지 않으면 아래처럼 3개의 파일이 모두 나온다.
--diff-filter=M을 사용한다면 아래처럼 수정된 파일들만 보인다.
--diff-filter=A를 사용한다면 추가된 파일만 볼 수 있다.
자세한 설명은 아래에서 확인할 수 있다.
https://git-scm.com/docs/git-diff#Documentation/git-diff.txt---diff-filterACDMRTUXB82308203
Git - git-diff Documentation
Show changes between the working tree and the index or a tree, changes between the index and a tree, changes between two trees, changes resulting from a merge, changes between two blob objects, or changes between two files on disk. git diff [ ] [--] [ …
git-scm.com
How to make git-diff and git log ignore new and deleted files?
Sometimes there's a couple of changed files together with some new, deleted and/or renamed files. When doing git diff or git-log I'd like to omit them, so I can better spot the modifications. Actu...
stackoverflow.com