vs code -> Extension -> git graph


๐ local์๋ ์์ฑ
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws (branch01)
$ git clone https://sxlbl:{ํ ํฐ}@github.com/sxlbl/log_project.git
Cloning into 'log_project'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), done.
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws (branch01)
$ ls
HelloGit/ branch_project/ log_project/ test_project/
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws (branch01)
$ cd log_project/
๐ cat๋ช
๋ น์ด๋ก ํ์ผ ์์ฑ
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/log_project (main)
$ cat > hello.py
print('hello workd')
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/log_project (main)
$ cat > hello.py
print('hello cat')
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/log_project (main)
$ cat >> hello.py
print('hello world')
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/log_project (main)
$ cat > hello.py
print('hello world')
๐งท
cat > | ํ์ผ์์ฑ, ๋ถํ์ฐ๊ธฐ
cat >> | ํ์ผ์์ฑ, ์ถ๊ฐ๋ก์ฐ๊ธฐ
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/log_project (main)
$ git add hello.py
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/log_project (main)
$ git commit -m 'modify 1' hello.py
[main ec659cb] modify 1
1 file changed, 1 insertion(+)
create mode 100644 hello.py
๐ข ๋ง๋ฌ๋ eroor ๋ชจ์
- LF will be replaced by CRLF in ์๋ฌ
- ํด๊ฒฐ :
$git config --global core.autocrlf true- ์ฐธ๊ณ ๋งํฌ : https://velog.io/@realzu/Git-LF-will-be-replaced-by-CRLF-in-%EC%97%90%EB%9F%AC-%ED%95%B4%EA%B2%B0%EB%B2%95
- Your branch is ahead of 'origin/main' by 2 commit.
git reset HEAD^^: 2๊ฐ ์ด์ ๊น์ง commit ๋ด์ฉ์ ์ทจ์
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/log_project (main)
$ code .

-branch ์์ฑ, ํ์ผ์์ log ํ์ธ
๐ dev ๋ธ๋์น ์์ฑ ๋ฐ ์ด๋
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/log_project (main)
$ git checkout -b dev
Switched to a new branch 'dev'
๐ ํ์ธ
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/log_project (dev)
$ git branch
* dev
main
๐ ํ์ผ์์
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/log_project (dev)
$ cat > hello.py
print('hello, dog')
๐ commit
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/log_project (dev)
$ git commit -m 'modify 2' hello.py
[dev 00be21d] modify 2
1 file changed, 1 insertion(+), 1 deletion(-)

branch๋ณ ๋ณ๊ฒฝ์ด๋ ฅ์ ๋ณผ ์ ์๋ค.
์ ํ์ผ commit ์ ๋ฆฌ
1. main์์ hello.py create(์๋ฌ๋ก commit ๋ ๋ผ๊ฐ), modify1 ๊ฐ๊ฐ commit
2. dev์์ hello.py ์์ ํ modify 2๋ก commit
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/log_project (dev)
$ git checkout main
Switched to branch 'main'
Your branch is ahead of 'origin/main' by 1 commit.
(use "git push" to publish your local commits)
$ git log
commit ec659cb349088e142047bbf1c99a304c8f7efb97 (HEAD -> main)
Author: sxlbl <sb.112097#gmail.com>
Date: Mon Feb 5 14:27:48 2024 +0900
modify 1
commit 0a4c4026487de63024b9fb7483e94014d0e9ab22 (origin/main, origin/HEAD)
Author: ๋ฐ์๋น <154489441+sxlbl@users.noreply.github.com>
Date: Mon Feb 5 13:38:59 2024 +0900
Initial commit ๐์ต์ด์์ฑํ์ ๋ log
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/log_project (dev)
$ git log
commit 00be21df43ff94664134d231c5f78ecaec5636b3 (HEAD -> dev)
Author: sxlbl <sb.112097#gmail.com>
Date: Mon Feb 5 14:39:26 2024 +0900
modify 2
commit ec659cb349088e142047bbf1c99a304c8f7efb97 (main)
Author: sxlbl <sb.112097#gmail.com>
Date: Mon Feb 5 14:27:48 2024 +0900
modify 1
commit 0a4c4026487de63024b9fb7483e94014d0e9ab22 (origin/main, origin/HEAD)
Author: ๋ฐ์๋น <154489441+sxlbl@users.noreply.github.com>
Date: Mon Feb 5 13:38:59 2024 +0900
Initial commit
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws (master)
$ git config --global core.editor "code --wait"
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws (master)
$ git config --global core.editor
code --wait
๐ข wait์ vs code ์คํ ์ค์ git bash๋ฅผ ๋๊ธฐ (์ฌ์ฉํ์ง ์๊ฒ ๋ค)๋ ์ต์ ์ด๋ฏ๋ก ์ ์ธ์์ผ๋ ๊ด์ฐฎ์

-> vs์ฝ๋ ์คํ๋จ
[diff]
tool = vscode
[difftool "vscode"]
cmd = "code --wait --diff $LOCAL $REMOTE"
-> ์ ์ฝ๋์ถ๊ฐ
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws (master)
$ cd log_project/
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/log_project (dev)
$ cat hello.py
print('hello, dog')
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/log_project (dev)
$ git checkout main
Switched to branch 'main'
Your branch is ahead of 'origin/main' by 1 commit.
(use "git push" to publish your local commits)
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/log_project (main)
$ cat hello.py
print('hello, cat')
ํ์ฌ ๋ฉ์ธ branch์ ๊ฒฝ์ฐ hello.py ๋ด์ฉ์ด hello, cat
dev์ ๊ฒฝ์ฐ 'hello, dog'์ผ๋ก ์ธํ
๋์ด์์
์ฐจ์ด๋ฅผ ๋น๊ตํด์ ๋ณด๊ธฐ์ํด diff ๊ธฐ๋ฅ ์ฌ์ฉํ ๊ฒ.
๐งท branch ๊ฐ ๋น๊ต
1.git diff <branch1><branch2>
2.git difftool <branch1><branch2>
-> vscode ์คํ ์ฌ๋ถ y
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/log_project (main)
$ 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')
โก๏ธ git bash์ ์ถ๋ ฅ
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/log_project (main)
$ git difftool main dev
Viewing (1/1): 'hello.py'
Launch 'vscode' [Y/n]? y

โก๏ธ vs code๋ก ์ถ๋ ฅ
๐งท Commit ๊ฐ ๋น๊ต
git diff (or difftool) <commithash> <commithash>
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/log_project (main)
$ git log
commit ec659cb349088e142047bbf1c99a304c8f7efb97 (HEAD -> main)
Author: sxlbl <sb.112097#gmail.com>
Date: Mon Feb 5 14:27:48 2024 +0900
modify 1
commit 0a4c4026487de63024b9fb7483e94014d0e9ab22 (origin/main, origin/HEAD)
Author: ๋ฐ์๋น <154489441+sxlbl@users.noreply.github.com>
Date: Mon Feb 5 13:38:59 2024 +0900
Initial commit
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/log_project (main)
$ git diff ec659cb349088e142047bbf1c99a304c8f7efb97 0a4c4026487de63024b9fb7483e94014d0e9ab22
diff --git a/hello.py b/hello.py
deleted file mode 100644
index 0fd4867..0000000
--- a/hello.py
+++ /dev/null
@@ -1 +0,0 @@
-print('hello, cat')
๐ ์ ์ค์ต ์ค create commit์ด ๋ ๋ผ๊ฐ์ ๋น๊ตํ ์๊ฐ ์์์ผ๋, ์ผ๋จ ํ๋๋ฐฉ๋ฒ๋ง ๊ธฐ๋กํ๋๋ก ํ๋ค.
๐งท ๋ง์ง๋ง Commit ๊ณผ ์ด์ Commit ๋น๊ต
git diff (or difftool) HEAD HEAD^
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/log_project (main)
$ git checkout dev
Switched to branch 'dev'
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/log_project (dev)
$ git diff HEAD HEAD^
diff --git a/hello.py b/hello.py
index 96b5a66..0fd4867 100644
--- a/hello.py
+++ b/hello.py
@@ -1 +1 @@
-print('hello, dog')
+print('hello, cat')
๐งท Git Diff - ๋ง์ง๋ง Commit ๊ณผ ํ์ฌ ์์ ์ฌํญ ํ์ธ
git diff (or difftool) HEAD
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/log_project (dev)
$ git checkout main
Switched to branch 'main'
Your branch is ahead of 'origin/main' by 1 commit.
(use "git push" to publish your local commits)
๐ ๋ง์ง๋ง commit ํ์ธ
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/log_project (main)
$ cat hello.py
print('hello, cat')
๐ ํ์ฌ์์ ์ฌํญ
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/log_project (main)
$ cat > hello.py
print('hello, pig')
๐ ํ์ธ
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/log_project (main)
$ git diff HEAD
diff --git a/hello.py b/hello.py
index 0fd4867..fa518fa 100644
--- a/hello.py
+++ b/hello.py
@@ -1 +1 @@
-print('hello, cat')
+print('hello, pig')
๐งทlocal๊ณผ Remote ๊ฐ์ ํ์ธ
git difftool main origin/main
origin : local
main : remote
๐ ํ์ฌ commit๊น์ง push
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/log_project (main)
$ git push origin main
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 16 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 288 bytes | 288.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To https://github.com/sxlbl/log_project.git
0a4c402..ec659cb main -> main
๐ local์์ ๋ณ๊ฒฝ์ฌํญ (pig) commit
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/log_project (main)
$ git commit -m 'modify 3' hello.py
[main 1baa9d5] modify 3
1 file changed, 1 insertion(+), 1 deletion(-)
โก๏ธ ์ฌ๊ธฐ์ remote์๋ cat, local์๋ pig ์ ๋ณด๋ก commit๋์ด์์
๐ ํ์ธ
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/log_project (main)
$ git diff origin/main
diff --git a/hello.py b/hello.py
index 0fd4867..fa518fa 100644
--- a/hello.py
+++ b/hello.py
@@ -1 +1 @@
-print('hello, cat')
+print('hello, pig')
- GitHub ์์ Remote Repository ์์ฑ
โข ์ด๋ฆ : diff_project
โข ์ต์ : README.md

- Local ์ Clone
โข ์์น : git_ws ํด๋
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws (master)
$ git clone https://sxlbl:{ํ ํฐ}@github.com/sxlbl/diff_project.git
Cloning into 'diff_project'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), done.
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws (master)
$ cd diff_project/
- Local Repository ์์ ํ์ผ ์์ฑ ํ Push
โข text.txt
โข ํ์ผ ๋ด์ฉ : my name is noma
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/diff_project (main)
$ cat text.txt
cat: text.txt: No such file or directory
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/diff_project (main)
$ cat > text.txt
my name is nama
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/diff_project (main)
$ ls
README.md text.txt
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/diff_project (main)
$ git status
On branch main
Your branch is up to date with 'origin/main'.
Untracked files:
(use "git add <file>..." to include in what will be committed)
text.txt
nothing added to commit but untracked files present (use "git add" to track)
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/diff_project (main)
$ git add text.txt
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/diff_project (main)
$ git status
On branch main
Your branch is up to date with 'origin/main'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: text.txt
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/diff_project (main)
$ git commit -m 'create text.txt' text.txt
[main c88c8d6] create text.txt
1 file changed, 1 insertion(+)
create mode 100644 text.txt
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/diff_project (main)
$ git push origin main
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 16 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 285 bytes | 285.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To https://github.com/sxlbl/diff_project.git
7aba2a4..c88c8d6 main -> main
- Main Branch ์์ ํ์ผ ์์ ํ ๋ง์ง๋ง commit ํ ๋ด์ฉ๊ณผ ๋น๊ต
โข ํ์ผ ์์ : my name is zero.
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/diff_project (main)
$ cat > text.txt
my name is zero
๐ ๋ง์ง๋ง commit๊ณผ ํ์ฌ ์์ ์ฌํญ ํ์ธ
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/diff_project (main)
$ git diff HEAD
diff --git a/text.txt b/text.txt
index c69171b..bc63d8e 100644
--- a/text.txt
+++ b/text.txt
@@ -1 +1 @@
-my name is nama
+my name is zero
- Main Branch ์์ ์์ ํ ๋ด์ฉ์ commit ํ ๋ค Remote Server ์ ๋น๊ต
๐ ์์ ๋ด์ฉ ํ์ธ
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/diff_project (main)
$ cat text.txt
my name is zero
๐ commit
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/diff_project (main)
$ git commit -m 'modify 1' text.txt
[main a06918b] modify 1
1 file changed, 1 insertion(+), 1 deletion(-)
๐ remote <> local ๋น๊ต
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/diff_project (main)
$ git diff main origin/main
diff --git a/text.txt b/text.txt
index bc63d8e..c69171b 100644
--- a/text.txt
+++ b/text.txt
@@ -1 +1 @@
-my name is zero
+my name is nama
- Dev Branch ์์ฑ ํ ์ด๋, ํ์ผ์ ์์ ํ ๋ค Master Branch ์ ๋น๊ต
โข Branch ์ด๋ฆ : dev
โข ํ์ผ ์์ : my name is base. (commit)
๐ dev ์์ฑ ํ ์ด๋
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/diff_project (main)
$ git checkout -b dev
Switched to a new branch 'dev'
๐ ๋ง์ง๋ง text.txt ๋ด์ฉ ํ์ธ
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/diff_project (dev)
$ cat text.txt
my name is zero
๐ text.txt ๋ด์ฉ ์์
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/diff_project (dev)
$ cat > text.txt
my name is base
๐ add & commit
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/diff_project (dev)
$ git status
On branch dev
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: text.txt
no changes added to commit (use "git add" and/or "git commit -a")
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/diff_project (dev)
$ git add text.txt
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/diff_project (dev)
$ git status
On branch dev
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: text.txt
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/diff_project (dev)
$ git commit -m 'modify 2. base' text.txt
[dev ec6fc75] modify 2. base
1 file changed, 1 insertion(+), 1 deletion(-)
๐ main ๊ณผ dev ๋น๊ต
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/diff_project (dev)
$ git diff main dev
diff --git a/text.txt b/text.txt
index bc63d8e..340176e 100644
--- a/text.txt
+++ b/text.txt
@@ -1 +1 @@
-my name is zero
+my name is base
- Dev Branch ์์ ๋๋ฒ์งธ commit ๊ณผ ๋ง์ง๋ง commit ๋น๊ต
โข ๋๋ฒ์งธ Commit Message : create test.txt
โข ๋ง์ง๋ง Commit Message : modify name - base
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/diff_project (dev)
$ git log
๐ commit ec6fc755e1e062b90d28c0eb8c1ddbc60c986916 (HEAD -> dev)
Author: sxlbl <sb.112097#gmail.com>
Date: Mon Feb 5 16:52:20 2024 +0900
modify 2. base
commit a06918b74b313d48eaf4b75692465fbf725eb9f7 (main)
Author: sxlbl <sb.112097#gmail.com>
Date: Mon Feb 5 16:48:00 2024 +0900
modify 1
๐commit c88c8d6b0845d0a45ae2bc5d5e33ff5196fb5155 (origin/main, origin/HEAD)
Author: sxlbl <sb.112097#gmail.com>
Date: Mon Feb 5 16:40:41 2024 +0900
create text.txt
commit 7aba2a4d9b57a29dab2b2bd97e62d2326b1bb99b
Author: ๋ฐ์๋น <154489441+sxlbl@users.noreply.github.com>
Date: Mon Feb 5 16:35:40 2024 +0900
Initial commit
๐ commit ๊ฐ ๋น๊ต
๋ฐ์๋น@์๋น์gram MINGW64 ~/OneDrive/Documents/git_ws/diff_project (dev)
$ git diff ec6fc755e1e062b90d28c0eb8c1ddbc60c986916 c88c8d6b0845d0a45ae2bc5d5e33ff5196fb5155
diff --git a/text.txt b/text.txt
index 340176e..c69171b 100644
--- a/text.txt
+++ b/text.txt
@@ -1 +1 @@
-my name is base
+my name is nama
- Git Grpah ํ์ธ
โข VSCode ์์ diff_project ์ Git Graph ๋ฅผ Branch ๋ณ๋ก ํ์ธ
code.
