(GIT)Log / Diff

지며리·2023년 1월 12일
0

Git Editor를 VSCode로 환경설정하기

  1. git bash에 git config --global core.editor "code --wait" 입력
  • vim이 기본설정
  • VSCode로 설정 변경 권장
  • --wait 옵션(VSCode창이 닫히기 전에 터미널에서 작업 불가) 추가 권장
  1. git bash에 git config --global -e 입력
  2. VSCode 창에 다음 코드를 입력하여 Git Diff 설정 추가
	[diff]
		tool = vscode
	[difftool "vscode"]
		cmd = "code --wait --diff $LOCAL $REMOTE"

Git log

  • branch 별 변경이력을 볼 수 있음
  • 가장 최근 변경이력이 가장 위에 표기
  • 커밋 / 커밋번호 / 작성자 / 날짜 / 커밋메세지 단위로 표기

Git Diff

  1. remote repository에 diff_project 브랜치 생성 후 local에 clone
  2. diff_project로 이동

  1. local에서 'my name is noma'가 담겨있는 파일 test.txt 생성, add, commit


4. remote repository에 push
5. local repository에 test.txt파일 내용을 'my name is zero'로 갱신

  • remote의 test.txt 파일 상태: my name is noma
  • local의 test.txt 파일 상태
    • commit : my name is noma
    • 최근 수정본: my name is zero

git difftool HEAD

commit과 최근 수정본을 비교

  1. git difftool HEAD 입력 후 Y입력



7. local repository에 갱신된 test.txt파일을 commit

  • remote의 test.txt 파일 상태: my name is noma
  • local의 test.txt 파일 상태
    • commit : my name is zero
    • 최근 수정본: my name is zero

git difftool branch_name origin/branch_name

local과 remote 비교

  1. git difftool main origin/main 입력 후 Y입력


  1. local repository에 dev 브랜치 생성
  2. dev 브랜치의 test.txt파일 내용을 'my name is base'로 갱신, add, commit
  • remote의 test.txt 파일 상태: my name is noma
  • local(main) test.txt 파일 상태
    • commit : my name is zero
    • 최근 수정본: my name is zero
  • local(dev) test.txt 파일 상태
    • commit: my name is base
    • 최근 수정본: my name is base

git difftool branch_name1 branch_name2

branch간의 비교

  1. git difftool main dev 입력 후 Y입력

git difftool commit_hash1 commit_hash2

commit간의 비교

  1. git log 입력 후 비교하고 싶은 commit의 hashcode확인
  2. git log ffbbb5b1490664c14c389b83ddcd1a22522cfce3 5bf091238daa022430d406425598b184c7928bf1 입력 후 Y입력

git difftool HEAD HEAD^

최근 commit과 이전 commit을 비교

  • 예제 화면 생략
profile
호지자불여락지자

0개의 댓글