차이점 확인
git diff
- 마지막 버전과 working tree의 차이점 확인
- 녹색의 + 는 마지막 버전에서 추가된 내용
- 적색의 - 는 마지막 버전에서 삭제된 내용
$ vi hello.txt
$ git diff
warning: in the working copy of 'hello.txt', LF will be replaced by CRLF the next time Git touches it
diff --git a/hello.txt b/hello.txt
index 01e79c3..b6bebeb 100644
--- a/hello.txt
+++ b/hello.txt
@@ -1,3 +1,3 @@
1
2
-3
+four
git reset
- working tree를 마지막 버전으로 변경
- working tree의 작업을 초기화
$ git reset --hard
HEAD is now at 69d4907 message 3
$ git diff
git log
$ git log -p
commit ~452 (HEAD -> main)
Author: unknown <11@~~.com>
Date: Wed Sep 3 20:43:16 2025 +0900
message 3
diff --git a/hello.txt b/hello.txt
index 1191247..01e79c3 100644
--- a/hello.txt
+++ b/hello.txt
@@ -1,2 +1,3 @@
1
2
+3
diff --git a/hello2.txt b/hello2.txt
new file mode 100644
index 0000000..00750ed
--- /dev/null
+++ b/hello2.txt
@@ -0,0 +1 @@
+3
commit ~ec5
Author: unknown <11@~~.com>
Date: Wed Sep 3 20:29:20 2025 +0900
message 2
diff --git a/hello.txt b/hello.txt
index d00491f..1191247 100644
--- a/hello.txt
+++ b/hello.txt
@@ -1 +1,2 @@
1
+2
commit ~312
Author: unknown <11@~~.com>
Date: Wed Sep 3 20:21:52 2025 +0900
message 1
diff --git a/hello.txt b/hello.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/hello.txt
@@ -0,0 +1 @@
+1