git 사용법-2 (git 되돌리는 방법)

     

    코드를 짜다가 실수해서 되돌아가야 할 때

    git restore 파일명

    => 파일을 최근 commit으로 되돌려 줌

    git restore --source 커밋아이디 파일명

    => 입력한 파일이 특정 커밋아이디 시점으로 복구된다.

    git restore --staged 파일명

    => 복구와 상관없지만 특정파일을 staging 취소 할 수 있다.

     

     

    git revert 커밋아이디

    => commit을 되돌려줌, (commit을 지우는 것이 아닌 commit 하나를 취소한 commit을 하나 생성해줌)

    git revert HEAD

    => 최근 했던 commit 1개만 revert 해줌

    출처 :https://codingapple.com/course-status/

     

    git reset --hard 커밋아이디

    => 커밋이 생성될 때로 시간을 되돌려준다.

    git reset --soft 커밋아이디

    => 커밋한 파일만 staging area에 남는다

    git reset --mixed 커밋아이디

    => 커밋한 파일만 staging 되지 않은 상태가 된다.

    출처 : https://codingapple.com/course-status/

     

     

    댓글