그럼에도 불구하고

👨‍💻

[Git, GitHub] Gif Diff란? 본문

이모저모/Git, GitHub

[Git, GitHub] Gif Diff란?

zenghyun 2023. 7. 6. 16:49

Git Diff에 대해 알아보겠습니다.

 

 

 

[ Gif Diff ]

git diff 명령을 사용하면 commit, branch, file, 작업 디렉터리 간의 변경 사항을 볼 수 있습니다. 

 

또한 git status 및  git log와 같은 명령과 함께 git diff를 사용하여 레포지토리에 대한 더 나은 그림과 시간이 지남에 따라 변경된 방식을 얻을 수 있습니다. 

 

git diff는 저장소에서 어떤 작업도 하지 않으며, git status나 git log처럼 아무런 영향도 미치지 않습니다. 순수하게 정보를 주는 명령어입니다.

 

📌 git diff

git diff

 

이 명령은 다음 commit을 위해 stage에 등록되지 않은 워킹 디렉터리의 변경 사항을 모두 나열합니다. 

따라서 워킹 디렉터리와 stage 영역 간 변경 사항을 비교합니다.

 

📌 git diff HEAD

git diff HEAD

 

git diff HEAD를 실행하면, HEAD가 가리키는 최신 commit과 워킹 디렉토리 간의 차이를 보여줍니다.

 

📌 git diff --staged or --cached 

git diff --staged

git diff --cached

 

두 옵션 모두 stage에 등록된 변경사항만을 보여줍니다.

 

📌 diff-ing specific files 

git diff HEAD [filename]

git diff --staged [filename]

 

diff의 범위를 특정 파일이나 파일들로 좁혀서 확인할 수 있습니다.

 

📌 comparing branches 

git diff branch1..branch2

or 

git diff branch1 branch2

 

git diff를 사용해서 두 branch를 비교할 수도 있습니다. 

 

📌 comparing commits 

git diff commit1..commit2

or

git diff commit1 commit2

 

두 commit 간의 어떤 것이 변경되었는지 알려줍니다.

 

 

🏷️ 예제

https://plum-poppy-0ea.notion.site/Git-Diff-Exercise-f7829bd2783940cea14239022a6c37a9

 

Git Diff Exercise

This exercise comes with a starter repo that you will need to clone down to your machine. We will be working with two bands: Queen and Fleetwood Mac and their various lineups over the years.

plum-poppy-0ea.notion.site

 

Comments