git cheat sheet2
이 포스트는 여러 절로 구성되어 있습니다.
git에 대한 자세한 내용은 다음 책을 참고 바란다.
본 포스트에서는 commit 조작과 관련된 명령어를 정리하였다.
1. Checkout
git checkout [commit hash]: 해당 commit으로 파일상태 변경git checkout -: HEAD가 이전에 참조했던 commit으로 상태변경git checkout master: HEAD가 master를 참조git checkout HEAD~n: HEAD를 기준으로 n단계 이전 commit으로 상태변경
2. Undoing checkout

git reset: Staging area의 파일 전체를 unstaged 상태로 되돌리기git reset [파일명]: 해당 파일을 unstaged 상태로 되돌리기

git commit --amend: 최근 커밋을 수정하기git commit --amend -m "[commit 메시지]": 해당 메시지로 commit 수정하기

git reset [commit hash]: 해당 commit으로 브랜치의 참조를 변경git reset –-hard [commit hash]: working directory, staging area, commit 모두 resetgit reset –-mixed [commit hash]: working directory 유지, staging area, commit reset , default optiongit reset –-soft [commit hash]: working directory, staging area 유지, commit resetgit reset HEAD^: HEAD를 기준으로 직전의 commit으로 resetgit reset HEAD~[정수]: HEAD를 기준으로 정수 값 단계 전 commit으로 reset