๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Git

[Git] git add ์ทจ์†Œํ•˜๊ธฐ, git commit ์ทจ์†Œํ•˜๊ธฐ

by ์ฝ”๋”ฉํ•˜๋Š” ๋ถ•์–ด 2022. 6. 6.
๋ฐ˜์‘ํ˜•

git add ์ทจ์†Œํ•˜๊ธฐ

1. ํŒŒ์ผ ์ƒํƒœ๋ฅผ ํ™•์ธํ•œ๋‹ค.

$ git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
  modified:   index.html



2. git reset HEAD [์ทจ์†Œํ•  ํŒŒ์ผ๋ช…] ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•œ๋‹ค. ๋’ค์— ํŒŒ์ผ๋ช…์ด ์—†์œผ๋ฉด addํ•œ ์ „์ฒด ํŒŒ์ผ์„ ์ทจ์†Œํ•œ๋‹ค.

$ git reset HEAD index.html

 


3. ๋‹ค์‹œ ํŒŒ์ผ ์ƒํƒœ๋ฅผ ํ™•์ธํ•œ๋‹ค.

$ git status
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
  modified:   index.html

 

 

 

 

 

git commit ์ทจ์†Œํ•˜๊ธฐ

1. commit ๋ชฉ๋ก์„ ํ™•์ธํ•œ๋‹ค.

$ git log

 

 

2. ์ทจ์†Œํ•˜๊ณ ์‹ถ์€ commit๋“ค์„ ์ทจ์†Œํ•œ๋‹ค.

$ git reset HEAD~2 (๋งˆ์ง€๋ง‰ 2๊ฐœ์˜ commit์„ ์ทจ์†Œ)
๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€