더북(TheBook)

git log 명령으로 조회해 보니 작업을 취소하는 새로운 커밋이 추가되었습니다.

administrator@vmgate:~/gittest$ git log --oneline
78367d6 (HEAD -> master) Revert "Edit failure.txt again"
c04ba03 Merge branch 'newfile'
c1eea5f Close newfile
ae5674d Edit failure.txt again
fa7301f Create 2019AD.txt
5aba677 Edit failure.txt
bc8d4f5 Create failure.txt

git revert 명령은 지정한 커밋만 취소합니다. 해당 커밋에서 했던 작업 내용만 사라지며, 다른 파일에 영향을 미치지 않습니다.

administrator@vmgate:~/gittest$ cat failure.txt
l lived meaninglessly
l live so lm meaningless.
administrator@vmgate:~/gittest$ cat 2019AD.txt
Why have dreams that cannot be?
Why does this chaos kill me?

한 번 더 git revert 명령을 실행합니다. 커밋 ID 대신 포인터 HEAD를 지정하면 현재 작업 중인 master 가지의 가장 최근에 실시한 커밋을 대상으로 revert를 실시합니다. 결과적으로 방금 실시했던 작업을 다시 취소합니다.

administrator@vmgate:~/gittest$ git revert HEAD
신간 소식 구독하기
뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.