[Git] 커밋 결합 : rebase -i (squash)

한별·2023년 9월 22일
0

Git

목록 보기
8/13

⭐ rebase -i

💫 사용 예제

마지막 2개의 커밋을 하나의 커밋으로 결합할 것임

1. 명령어 실행

$ git rebase -i HEAD~~

→ 텍스트 편집기가 열림

⚠️ intitial commit을 선택하고 싶다면 다음 명령어를 사용

$ git rebase -i --root

2. 텍스트 편집기 수정

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로 변경한 다음 저장/종료
  • 새로운 커밋의 커밋 메시지를 편집한 다음 저장하고 종료

2. 실행 결과

이전 두 커밋은 이제 하나의 새 커밋으로 스쿼시됨


참고 자료

[nulab] 커밋 결합

profile
누구나 이해하기 쉽게 글 쓰고 싶은 FE 개발자

0개의 댓글

관련 채용 정보