튜토리얼 3: 커밋을 변경해보자!
5. rebase -i 로 커밋 모두 통합하기
이 튜토리얼에서는 사전에 이력이 준비되어 있는 로컬 저장소를 사용합니다.
여기에서 다운로드 해 주십시오.
위에서 다운로드 한 'stepup-tutorial/tutorial5' 폴더로 이동합니다. 이 저장소의 이력은 다음 그림과 같습니다. 이번에는 「commit의 설명을 추가」한 커밋과 「pull의 설명을 추가」한 커밋을 하나의 커밋으로 통합해 보도록 하겠습니다.
과거의 커밋을 통합할 때는 'rebase -i' 를 사용합니다.
$ git rebase -i HEAD~~
텍스트 에디터가 열리고 'HEAD'에서 'HEAD~~'까지의 커밋이 다음과 같이 표시됩니다.
pick 9a54fd4 commit의 설명 추가 pick 0d4a808 pull의 설명을 추가 # 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's 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로 변경하고 저장 · 종료합니다.
이로써 두 개의 커밋이 하나의 커밋으로 통합 되었습니다. log 명령어를 실행하여 이력을 확인합니다.