Git-타임캡슐?


git add & commit

  • git 상태확인: git status

  • git 타임캡슐(staging area)에 staging 하기: git add "file_name" or git add .

  • git 타임캡슐의 스냅샷 찍기:
    • git commit : vi 가 열리면서 comment 적을 수 있음
    • git commit -m "your_comment": 터미널에서 한줄 comment 달기
  • git 스냅샷 히스토리:
    • git log
1
2
3
4
5
6
7
8
9
#output
# "j": 아래로 스크롤
# "k": 위로 스크롤
# ":q": 나가기
commit a6bddd1d806b4db51f4568419296ac394f9665ab (HEAD -> main)
Author: neuralprobe <jhshin1026@gmail.com>
Date:   Tue Aug 9 07:04:01 2022 +0900

	First commit

코드 변경 example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# lions.yaml 지우고,
# tigers.yaml 수정하고,
# leopard.yaml 생성하면,
git status

# output
On branch main
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        deleted:    lions.yaml
        modified:   tigers.yaml

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        leopard.yaml
  • 변경 내역 비교해 보기!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
git diff
# "j": 아래로 스크롤
# "k": 위로 스크롤
# ":q": 나가기

#output
diff --git a/lions.yaml b/lions.yaml
deleted file mode 100644
index 416a903..0000000
--- a/lions.yaml
+++ /dev/null
@@ -1,8 +0,0 @@
-team: Lions
-
-manager: Mary
-
-members:
-- Thomas
-- Karen
-- Margaret
\ No newline at end of file
diff --git a/tigers.yaml b/tigers.yaml
index ebd5d76..480f6dc 100644
--- a/tigers.yaml
+++ b/tigers.yaml
@@ -1,6 +1,6 @@
 team: Tigers
 
-manager: John
+manager: Donald
 
 members:
 - Linda
~
~
(END)
  • 추가된 파일 (untracked file) 없을 경우엔, addcommit 한꺼번에 할 수 있음
1
git commit -am "your_comment"

Reference

Notes Mentioning This Note

Table of Contents


Share on: