Git | Commit Rebase
10 Jul 2021 | ETC.
git rebase -i
rebase는 일반적으로 commit message를 수정하거나 commit 자체를 삭제할 때 사용된다.
# interactive 옵션의 매개변수로 보고자 하는 commit의 수를 입력.
# HEAD를 기준으로 최근 N개의 commit을 보겠다.
git rebase -i HEAD~N
# ex) git rebase -i HEAD~3
# interactive 옵션의 매개변수로 commit 값을 입력.
# commit 해쉬값 이후의 모든 commit을 보겠다.
git rebase -i (commit hash value)
# git rebase -i 0069ab23cb8cc87a31983081887dbe2d30afceb0

git rebase -i에서 i는 interaction을 뜻한다. 그래서 입력한 범위에 대해 상호 수정이 가능한 editor가 열린다.

위 그림이 editor가 열린 화면인데, 보면 여러 명령어들이 있다. a를 누르고 좌측의 ‘pick’을 원하는 명령어로 고쳐주면 된다. 위 그림에서는 commit내용을 수정하기 위해 reword명령을 입력했다. 그리고 editor를 나오면(esc누르고 :wq!입력하면 됨) 아래와 같이 commit message 바꾸는 창이 뜬다.

똑같이 a눌러서 바꾸고 esc, :wq!해서 나오면 끝.
commit을 아예 삭제하고 싶으면 drop을 사용하면 된다. commit message만 삭제하는게 아니라 commit 자체를 삭제하는거라 만약 파일 생성 commit을 삭제하면 파일이 삭제된다.


git rebase –continue
git rebase --continue
rebase로 수정을 끝내고 나면 변경 내용을 저장하기 위해 위 명령을 입력해야 한다.
git rebase -i
rebase는 일반적으로 commit message를 수정하거나 commit 자체를 삭제할 때 사용된다.
# interactive 옵션의 매개변수로 보고자 하는 commit의 수를 입력.
# HEAD를 기준으로 최근 N개의 commit을 보겠다.
git rebase -i HEAD~N
# ex) git rebase -i HEAD~3
# interactive 옵션의 매개변수로 commit 값을 입력.
# commit 해쉬값 이후의 모든 commit을 보겠다.
git rebase -i (commit hash value)
# git rebase -i 0069ab23cb8cc87a31983081887dbe2d30afceb0

git rebase -i에서 i는 interaction을 뜻한다. 그래서 입력한 범위에 대해 상호 수정이 가능한 editor가 열린다.

위 그림이 editor가 열린 화면인데, 보면 여러 명령어들이 있다. a를 누르고 좌측의 ‘pick’을 원하는 명령어로 고쳐주면 된다. 위 그림에서는 commit내용을 수정하기 위해 reword명령을 입력했다. 그리고 editor를 나오면(esc누르고 :wq!입력하면 됨) 아래와 같이 commit message 바꾸는 창이 뜬다.

똑같이 a눌러서 바꾸고 esc, :wq!해서 나오면 끝.
commit을 아예 삭제하고 싶으면 drop을 사용하면 된다. commit message만 삭제하는게 아니라 commit 자체를 삭제하는거라 만약 파일 생성 commit을 삭제하면 파일이 삭제된다.


git rebase –continue
git rebase --continue
rebase로 수정을 끝내고 나면 변경 내용을 저장하기 위해 위 명령을 입력해야 한다.