[Git] git flow, git rebase
![post-thumbnail](https://velog.velcdn.com/images/yjoct13/post/6bb2adda-af0a-4bf0-a763-ab4f03ff4b2a/image.png)
merge의 단점
- 불필요한 merge commit 생성
- 복잡한 프로젝트 history
![](https://velog.velcdn.com/images/yjoct13/post/8663e67c-cc15-4a9f-afc2-ae7481d059bc/image.png)
rebase의 장점
- 같은 feature에서 작업했던 것들을 모을 수 있어 history 보기가 더 쉬워짐
![](https://velog.velcdn.com/images/yjoct13/post/9021295d-acae-4603-9d11-dcbea0131143/image.png)
rebase 방법
<새로운 작업을 모두 마치고 push 하기 전>
- main branch 이동 후 remote main을 pull 받음
- push 할 feature branch로 이동
git rebase -i main
<rebase 진행 중 squash를 할 때>
- 가장 오래된 (최상단) commit을 pick 함
- 다른 커밋 메세지는 가장 오래된 commit을 기준으로 squash
- esc -> :wq
rebase 중 conflict 해결 방법
- 해당 코드 수정
git add .
(cf. commit은 수정 사항이 없으므로 하지 않는다.)
git rebase --continue
- 멈춰 있던 rebase가 진행됨
- conflict이 여러번 발생할 경우 그때마다 해결 후
gid add .
& git rebase --continue
반복
- 계속 해결이 안 될 경우
git rebase --abort
를 통해 아예 rebase 전 상황으로 돌아갈 수 있다.