1 개요[ | ]
- git reset
- HEAD를 특정 commit 시점으로 되돌리는 git 명령어
2 실습[ | ]
- 사전작업: git commit 실습
Console
Copy
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(+)
Console
Copy
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!
Console
Copy
root@zetawiki:~/workspace/hello# git reset 6b03476
Unstaged changes after reset:
M greet.txt
Console
Copy
root@zetawiki:~/workspace/hello# git log
commit 6b0347639d7cb7a6a2f9d9c2eb239c66f152562a
Author: gituser1 <gituser1@zetawiki.com>
Date: Wed Mar 2 00:09:16 2016 +0900
hello world!
Console
Copy
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 참고[ | ]
편집자 John Jeong
로그인하시면 댓글을 쓸 수 있습니다.