Log and Diff

eunbi kim·2024년 4월 12일
0
  • Git Log
  • Git Editor
  • Git Diff

Git Log

Branch별 변경 이력을 볼 수 있다.

git log

-> remote에서 최초 생성, create로 커밋, modify 1 modify 2 까지의 일련의 과정들이 보인다.

VScode에서 git graph로 이 과정들을 좀 더 간편하게 볼 수 있다.

Git Editor

--wait 옵션 <- command line으로 vscode를 실행시켰을 경우 vscode 인스턴트를 닫을 때까지 command를 대기

git config --global core.editor <editorname> --wait

Git Diff

버전간의 차이점을 조회하게 해주는 명령. 터미널에서 확인하기에는 가독성이 떨어지므로
Vscode를 사용하여 조회하자

  • Git Configuration 파일 열기
git config --global -e
  • Git Diff 설정 추가
    Git Diff 툴을 vscode로 설정하겠다, wait옵션
[diff]
	tool = vscode
[difftool "vscode"]
    cmd = "code --wait --diff $LOCAL $REMOTE"
  • Git Diff - Local Branch간 비교
git diff <branch1> <branch2>

예를 들어
main과 dev 브랜치간의 차이점을 보려면,
(vscode로 보려면 difftool 입력 후 launch vscode?-> yes)

-> vscode에서 diff부분을 색으로 표시하여 보여준다. dev브랜치에서 hello cat을 hello dog로 수정하여 커밋한 흔적을 볼 수 있다.

  • Git Diff - Commit간 비교

브랜치간의 비교가 아니라, 버전간의 비교는 각 버전의 커밋해시를 알아야 한다.
git log로 조회할 수 있고 깃헙에서 확인할 수도 있다.

git diff <commithash> <commithash>

create와 modify1 비교: hello world에서 hello cat으로 바뀜

  • Git Diff - 마지막 Commit과 이전 Commit 비교
git diff HEAD HEAD^
  • Git Diff - 마지막 Commit과 현재 수정사항 확인
> git diff HEAD
  • Git Diff - Local/Remote간 비교
git diff <branch> origin/<branch2>

0개의 댓글