Git reset

1 개요[ | ]

git reset
  • HEAD를 특정 commit 시점으로 되돌리는 git 명령어

 

2 실습[ | ]

root@zetawiki:~/workspace/hello# echo 'good morning' >> greet.txt
root@zetawiki:~/workspace/hello# git add greet.txt 
root@zetawiki:~/workspace/hello# git commit -m 'good morning!'
[master c88bffe] good morning!
 1 file changed, 1 insertion(+)
root@zetawiki:~/workspace/hello# git log
commit c88bffe4d7e3389a01704ef51390257ad38d0e95
Author: gituser1 <gituser1@zetawiki.com>
Date:   Wed Mar 2 00:09:26 2016 +0900

    good morning!

commit 6b0347639d7cb7a6a2f9d9c2eb239c66f152562a
Author: gituser1 <gituser1@zetawiki.com>
Date:   Wed Mar 2 00:09:16 2016 +0900

    hello world!
root@zetawiki:~/workspace/hello# git reset 6b03476
Unstaged changes after reset:
M	greet.txt
root@zetawiki:~/workspace/hello# git log
commit 6b0347639d7cb7a6a2f9d9c2eb239c66f152562a
Author: gituser1 <gituser1@zetawiki.com>
Date:   Wed Mar 2 00:09:16 2016 +0900

    hello world!
root@zetawiki:~/workspace/hello# cat greet.txt
hello world
good morning
root@zetawiki:~/workspace/hello# git checkout greet.txt
root@zetawiki:~/workspace/hello# cat greet.txt
hello world

3 옵션[ | ]

옵션 HEAD Index Working Directory
git reset --soft [commit] o x x
git reset --mixed [commit] o o x
git reset --hard [commit] o o o
→ o 로 표시된 부분만 실행됨
→ 옵션 없이 git reset [commit] 을 실행하면 mixed 옵션으로 실행됨

4 같이 보기[ | ]

5 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}