Skip to main content
  1. Learn center
  2. Software Development
  3. Guides
  4. Git tutorial
  5. Git 사용 방법
  6. Git에서 기록을 관리하는 방법
  7. 커밋 취소
GuidesSoftware DevelopmentBacklog
Git

Project and code management together.

커밋 취소

이전에 다운로드한 git-tutorial/tutorial2 디렉터리로 이동합니다.

이 저장소의 기록을 검토하면 다음과 같이 표시됩니다

Current history

Git revert 명령을 사용하여 "append description of the pull command" 커밋을 실행 취소합니다.

먼저 sample.txt 파일을 열고 내용이 다음과 같은지 확인합니다.

Anyone can learn Git with this tutorial and Backlog
add: Register a change in an index
commit: Save the status of an index
pull: Obtain the content of the remote repository

다음과 같이 revert 명령을 사용하여 "append description of the pull command"라는 최신 HEAD 커밋을 실행 취소합니다.

$ git revert HEAD
[main d47bb1d] Revert "append description of the pull command"
  1 files changed, 1 insertions(+), 2 deletions(-)

이제 sample.txt를 열면 마지막 라인(예: "pull: Obtain the content of the remote repository")이 더 이상 존재하지 않는 것을 볼 수 있습니다.

The history of repository after the revert

Git log 명령을 사용하여 새 기록이 다음과 같은지 확인하십시오.

$ git log
  commit 7bcf5e3b6fc47e875ec226ce2b13a53df73cf626
  Author: yourname <yourname@yourmail.com>
  Date:   Wed Jul 18 15:46:28 2022 +0900

      Revert "append description of the pull command"

      This reverts commit 0d4a808c26908cd5fe4b6294a00150342d1a58be.

  commit 0d4a808c26908cd5fe4b6294a00150342d1a58be
  Author: yourname <yourname@yourmail.com>
  Date:   Mon Jul 16 23:19:26 2022 +0900

      append description of the pull command

  commit 9a54fd4dd22dbe22dd966581bc78e83f16cee1d7
  Author: yourname <yourname@yourmail.com>
  Date:   Mon Jul 16 23:19:01 2022 +0900

      append description of the commit command

  commit 326fc9f70d022afdd31b0072dbbae003783d77ed
  Author: yourname <yourname@yourmail.com>
  Date:   Mon Jul 16 23:17:56 2022 +0900

      append description of the add command

  commit 48eec1ddf73a7fb508ef664efd6b3d873631742f
  Author: yourname <yourname@yourmail.com>
  Date:   Mon Jul 16 23:16:14 2022 +0900

      first commit

Subscribe to our newsletter

Learn with Nulab to bring your best ideas to life