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/tutorial5 디렉터리로 이동합니다.

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

Current history

"append description of the commit command"와 "append description of the pull command"라는 두 커밋을 하나의 커밋으로 결합합니다.

이를 위해 git rebase -i 명령을 사용합니다.

$ git rebase -i HEAD~~

기본 텍스트 편집기가 열리면 rebase-interactive 모드가 됩니다. 아래와 같이 HEAD에서 HEAD~~까지 커밋이 표시됩니다.

pick 9a54fd4 append description of the commit command
  pick 0d4a808 append description of the pull command

  # Rebase 326fc9f..0d4a808 onto d286baa
  #
  # Commands:
  #  p, pick = use commit
  #  r, reword = use commit, but edit the commit message
  #  e, edit = use commit, but stop for amending
  #  s, squash = use commit, but meld into previous commit
  #  f, fixup = like "squash," but discard this commit log message
  #  x, exec = run command (the rest of the line) using shell
  #
  # If you remove a line here THAT COMMIT WILL BE LOST.
  # However, if you remove everything, the rebase will be aborted.
  #

두 번째 라인에서 pick이라는 단어를 squash로 변경한 다음 저장하고 종료합니다.

그런 다음 편집기는 새로 구성된 이 커밋의 커밋 메시지를 편집하라는 메시지를 표시합니다. 커밋 메시지를 편집한 다음 저장하고 종료합니다.

이전 두 커밋은 이제 하나의 새 커밋으로 스쿼시됩니다.

Git log 명령을 사용하여 기록 로그를 확인하여 결과를 확인합니다.

Organize commit

Subscribe to our newsletter

Learn with Nulab to bring your best ideas to life