[Git] 커밋 수정 2 : rebase -i (edit)

한별·2023년 9월 22일
0

Git

목록 보기
9/13

⭐ rebase -i

💫 사용 예제

HEAD 이전 커밋을 수정할 것임

1. 명령어 실행

$ git rebase -i HEAD~~

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 → edit로 변경 후 저장/종료

3. 파일 수정

Sample.txt 파일을 열고 변경

4. 변경 사항 add 및 commit

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

5. rebase 프로세스 종료

$ git rebase --continue

⚠️ Rebase 중 conflict 발생한 경우

충돌을 수동으로 해결
git addgit rebase --continue 실행

⚠️ Rebase 중지

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

참고 자료

[nulab] 커밋 결합 및 이동

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

0개의 댓글

관련 채용 정보