깃허브에서 log_project Repository 만든 후
로컬로 clone 해와서
log_project 에서 아래처럼 명령어 입력 진행
- cat <filename>
: 파일 내용 읽어오기
- cat > <filename>
: 파일에 내용 덮어쓰기
- cat >> <filename>
: 파일에 내용 추가하기
Branch별 변경이력을 볼 수 있음
해당 branch로 이동(git checkout) 후 로그 확인(git log)
git log
--wait 옵션은 command line 으로 VSCode 를 실행시켰을 경우,
VSCode 인스턴스를 닫을 때까지 command 를 대기
git config --global core.editor <editorname> --wait
$ git config --global core.editor "code --wait"
$ git config --global core.editor "vim"
# esc : 명령모드
# i : 편집모드(insert)
# 명령모드에서 q! 하면 빠져나와짐
버전 간에 차이점을 확인할 수 있는 툴
git config --global -e
열린 vscode의 git configuration 창에서 내용 추가하고 끄기 (다시 git bash로 돌아감)
[diff]
tool = vscode
[difftool "vscode"]
cmd = "code --wait --diff $LOCAL $REMOTE"
git diff <branch1> <branch2>
실습1 - git bash (git diff)
log_project % git diff main dev
diff --git a/hello.py b/hello.py
index 0fd4867..96b5a66 100644
--- a/hello.py
+++ b/hello.py
@@ -1 +1 @@
-print('hello, cat')
+print('hello, dog')
실습2 - vscode (git difftool)
log_project % git difftool main dev
Viewing (1/1): 'hello.py'
Launch 'vscode' [Y/n]? y
git diff <commithash> <commithash>
: git log 했을 때 commit 뒤의 문자열
create 과 modify 1 비교
log_project % git difftool 01c920522ae2dccc7205a6d31a0333854816bc66
23cd33c423fdbf9759c1a0923a0a2bc51beb2fd2
Viewing (1/1): 'hello.py'
Launch 'vscode' [Y/n]? y
git diff HEAD HEAD^
log_project % git difftool HEAD HEAD^
Viewing (1/1): 'hello.py'
Launch 'vscode' [Y/n]? y
git diff HEAD
log_project % cat > hello.py
print('hello, pig')
# 아직 commit 하기 전 현재
log_project % git difftool HEAD
Viewing (1/1): 'hello.py'
Launch 'vscode' [Y/n]? y
git diff <branch> origin/<branch2>
현재 폴더를 VSCode 로 열기 위해 아래와 같은 명령어 입력
log_project % code .
GitHub 에서 Remote Repository 생성
• 이름 : diff_project
• 옵션 : README.md
Local 에 Clone
• 위치 : git_ws 폴더
git clone ~~
cat > text.txt
my name is noma.
git add text.txt
git commit -m 'create text.txt' text.txt
git push origin main
cat > text.txt
my name is zero.
git difftool HEAD
>> noma, zero
git commit -m 'modify name - zero' text.txt
# commit 후, push 전
git difftool main origin/main
>> zero, noma
git checkout -b dev
cat > text.txt
my name is base.
git add text.txt
git commit -m 'modify -base' text.txt
git difftool main dev
>>zero, base
(dev branch에서)
git log
>> hashcode 확인
git difftool 52821742166059d409a310affb30da2aa433376a 8e824fb063a62d73772ed62318e4968f911daa07
>> noma, base
code .
> source control