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

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

Current history

"append description of the commit command"라는 메시지로 커밋을 수정할 것입니다.

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

$ git rebase -i HEAD~~

기본 텍스트 편집기는 아래와 같이 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이라는 단어를 edit로 변경한 다음 저장하고 종료합니다.

다음 출력이 표시되고 해당 커밋에서 체크아웃됩니다.

Stopped at d286baa... append description of the commit command
  You can amend the commit now, with

          git commit --amend

  Once you are satisfied with your changes, run

          git rebase --continue

sample.txt 파일을 열고 아래와 같이 변경합니다.

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

git commit --amend를 사용하여 변경 사항을 커밋합니다.

$ git add sample.txt
$ git commit --amend

그런 다음 git rebase --continue를 실행하여 리베이스 프로세스를 완료합니다.

$ git rebase --continue

현재 브랜치에서 리베이스를 실행하는 동안 변경 사항에서 충돌이 발생할 수 있습니다. 계속하려면 이러한 충돌을 수동으로 해결한 다음 git addgit rebase --continue를 실행해야 합니다. 충돌을 해결하기 위해 새 커밋을 실행할 필요가 없습니다.

그러나 리베이스를 중지하려면 git rebase --abort를 호출하면 전체 프로세스를 되돌리고 종료하고 커밋을 성공적으로 수정할 수 있습니다.

git rebase -i를 호출할 때 한 라인 이상에 edit를 지정하는 경우 각 커밋을 한 번에 하나씩 수정하라는 메시지가 표시됩니다.

Subscribe to our newsletter

Learn with Nulab to bring your best ideas to life