develog

[git] reset 본문

Dev/git

[git] reset

냐옴 2022. 4. 3. 22:19

reset 을 하면

- reset 한 커밋, 이후 로그가 삭제되고

- reset 한 커밋, 이후 수정내용이 unstaged 상태로 바뀐다

 

  • reset 실행 전
$ git log --oneline
0a2d818 (HEAD -> master) add section 2
6ced8d4 add section
49e50c8 change title ## reset 할 커밋
26d36a0 add index.html

$ git status
On branch master
nothing to commit, working tree clean
  • reset 실행
$ git reset 49e50c8
Unstaged changes after reset:
M	index.html
  • reset 실행 후
## reset 한 커밋 이후 삭제된다
$ git log --oneline
49e50c8 (HEAD -> master) change title
26d36a0 add index.html

## reset 한 커밋 이후 수정내용이 unstaged 상태로 바뀐다
$ git status
On branch master
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:   index.html

no changes added to commit (use "git add" and/or "git commit -a")

'Dev > git' 카테고리의 다른 글

[git] switch  (0) 2022.04.03
[git] clone vs fork  (0) 2022.04.03
[git] revert  (0) 2022.04.03
[git] checkout commit  (0) 2022.04.01
[git] master >R>  (0) 2022.03.31
Comments