# rebase할 브랜치[feature]로 이동
$ git checkout feature
# 합칠 브랜치[master]를 rebase
$ git rebase master
# 최근 두개의 커밋을 통합
$ git rebase -i head~~
# 수정한 커밋 메시지 반영
# git rebase --continue
# --onto 옵션을 사용하여 3개의 브랜치중 2개의 브랜치만 합칠 때
# server 브랜치만 놔두고 client 브랜치만 master브랜치의 합치는 예제
$ git rebase --onto master server client
# issue53 브랜치의 커밋 내용을 master 브랜치로 묶고 싶을때
$ git checkout master
$ git merge --squash issue53
# 되돌려야 할 커밋을 찾음
$ git log
# 해당 커밋의 해쉬를 찾고 다음 명령어를 입력하면
$ git revert [saved hash]
# git이 해당 커밋을 되돌리는 새로운 커밋을 생성함
# 에이터창이 나타나면 새로운 커밋 메시지를 입력하거나
# 그냥 저장하면 됨.
# 에디터가 켜지고 메시지를 수정할 수 있음.
$ git commit --amend
참고
- Dangit, Git!?!(https://dangitgit.com/ko)
- Git 브랜치 - merge하기(https://git-scm.com/book/ko/v2/Git-%EB%B8%8C%EB%9E%9C%EC%B9%98-%EB%B8%8C%EB%9E%9C%EC%B9%98%EC%99%80-Merge-%EC%9D%98-%EA%B8%B0%EC%B4%88#_basic_merging)
- Git 브랜치 - Rebase하기(https://git-scm.com/book/ko/v2/Git-%EB%B8%8C%EB%9E%9C%EC%B9%98-Rebase-%ED%95%98%EA%B8%B0)