Git_3

YJ·2023년 4월 26일
0

▷ 오늘 학습 계획: Git 강의(5~6)

📖 06_Log and Diff

1) Git Log

Branch 별 변경이력을 볼 수 있음

  • master → dev로 branch를 수정한 경우, dev branch로 이동해서 로그 이력을 확인하면 master branch에서 진행된 내용도 공통으로 나온다.
  • 날짜순으로(최근 내용이 위에 있음) 조회된다.

2) Git Editor 설정

git config --global core.editor "vim"
# VS code로 editor 설정하기
git config --global core.editor "code --wait"
  • --wait 옵션: command line 으로 VSCode 를 실행시켰을 경우
    VSCode 인스턴스를 닫을 때까지 command 를 대기

3) Git Diff Tool 설정

Git Configuration 파일 열기

git config --global -e

Git Diff 설정 추가

[diff]
	tool = vscode
[difftool "vscode"]
	cmd = "code --wait --diff $LOCAL $REMOTE"

4) Git Diff

Local Branch 간 비교

git diff <branch1> <branch2>
git difftool <barnch1> <branch2>

Commit 간 비교

git diff <commithash> <commithash>
git difftool <commithash> <commithash>

마지막 Commit 과 이전 Commit 비교

git diff HEAD HEAD^

마지막 Commit 과 현재 수정사항 확인

git diff HEAD

Local, Remote 비교

git diff <branch> origin/<branch2>

참고) cat 명령

# 새로운 파일 생성(원래 있던 파일이면 내용 덮어쓰기)
cat > hello.py
print('hello, world')
# 내용 덧붙이기
cat >> hello.py
print('hello, cat')
# 해당 파일에 기재된 내용 출력
cat hello.py

📖 07_Merge and Conflict

1) Merge Tool 설정

Git Configuration 파일 열기

git config --global -e

Git Merge 설정 추가

[merge]
	tool = vscode
[mergetool "vscode"]
	cmd = "code --wait $MERGED"

2) Merge

현재 위치한 Branch 에 다른 Branch 를 병합

git merge <branchname>

3) Conflict

Branch 를 Merge 하는 과정 또는 Push, Pull 과정에서 충돌

git merge dev2  # Conflict 발생
git mergetool  # VSCode 에서 Conflict 파일 수정
git add test.txt  # Conflict 해제 
git commit  # Commit Message 저장하기 
git log

▷ 내일 학습 계획: Git 강의(7~9)

[이 글은 제로베이스 데이터 취업 스쿨의 강의 자료 일부를 발췌하여 작성되었습니다.]

0개의 댓글