➡ 지금까지 내가 commit한 로그와 메세지를 볼 수 있다.
1️⃣ git log -p
➡ -p는 옵션값.
➡ 커밋과 커밋 사이의 소스 상에 차이를 알 수 있다.
👉 --- a/파일명 : 이전버전
👉 +++ b/파일명 : 현재버전 - 수정된 내용
➡ 커밋과 커밋 사이의 소스 코드 상에 차이점(변화)을 보여준다
📍 git add ➡ commit ➡ push ➡ log
PS C:\co-project> git add .
PS C:\co-project> git commit -m "fourth commit"
[ssnhhyejin d0ce872] fourth commit
1 file changed, 12 insertions(+)
create mode 100644 toy2.html
PS C:\co-project> git push origin ssnhhyejin
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 462 bytes | 462.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To github.com:ssnhhyejin/toy_project.git
da26c24..d0ce872 ssnhhyejin -> ssnhhyejin
PS C:\co-project> git log
commit d0ce8721c9c78c17b98b39d941a7d356a60c06c9 (HEAD -> ssnhhyejin, origin/ssnhhyejin)
Author: ssnhhyejin <ssnhhyejin@gmail.com>
Date: Wed Feb 22 10:24:03 2023 +0900
fourth commit
commit da26c24c9f0c4c5dbba0c9921e63a6ec88aac4de
Author: ssnhhyejin <ssnhhyejin@gmail.com>
Date: Wed Feb 22 10:21:34 2023 +0900
third commit
📍 git diff
1️⃣git diff
➡ working directory와 staging area 사이의 차이를 확인하기 위한 명령어
단, git add를 통해 staging area로 넘어갔으면 git diff에는 아무것도 나타나지 않는다
☝ 소스 추가 후, add 하지 않고 바로 git diff 실행
➡ 그래야 stage area에 들어가지 않은 파일과 이미 repository에 존재하는 파일의 차이를 볼 수 있음
📍 git diff 커밋ID..커밋ID
2️⃣git diff 커밋ID..커밋ID
➡ 커밋 사이 별 변화를 보여준다
ssnhh@DESKTOP-9APISNT MINGW64 /c/co-project (ssnhhyejin)
$ git diff d0ce8721c9c78c17b98b39d941a7d356a60c06c9..da26c24c9f0c4c5dbba0c9921e63a6ec88aac4de
diff --git a/toy2.html b/toy2.html
deleted file mode 100644
index 4f58c74..0000000
--- a/toy2.html
+++ /dev/null
@@ -1,12 +0,0 @@
-<!DOCTYPE html>
-<html lang="ko">
-<head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>toy2</title>
-</head>
-<body>
- <h1>Hi, This is the toy2</h1>
-</body>
-</html>
\ No newline at end of file
📍 git diff 브랜치..브랜치
3️⃣git diff 브랜치..브랜치
➡ 브랜치와 브랜치 사이의 차이를 보여준다
ssnhh@DESKTOP-9APISNT MINGW64 /c/co-project (ssnhhyejin)
$ git diff main..ssnhhyejin
diff --git a/toy.html b/toy.html
index d4a0a45..8d91173 100644
--- a/toy.html
+++ b/toy.html
@@ -11,5 +11,11 @@
<p> I'll make new branch
And push
</p>
+
+ <p> Add the new one
+
+ And plus the test part
+ </p>
+
</body>
</html>
\ No newline at end of file
diff --git a/toy2.html b/toy2.html
new file mode 100644
index 0000000..4f58c74
--- /dev/null
+++ b/toy2.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="ko">
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>toy2</title>
+</head>
+<body>
+ <h1>Hi, This is the toy2</h1>
+</body>
+</html>
\ No newline at end of file
📌정리: log는 지금까지의 commit한 내용들을 쭉 보여주는 거라면 diff는 staging area에 들어가기 전, 커밋과 커밋 사이, 브랜치와 브랜치의 차이 즉 변화를 보여주는 명령어이다