git rebase

이지훈·2021년 7월 20일
0

git

목록 보기
3/3
post-thumbnail

1. git merge main

👉🏼 불필요한 merge commit 생성
모든 feature branch마다 merge commit 이 남습니다. 만약 main 브랜치를 공유하는 개발자가 많고, 프로젝트의 규모가 크다면,
branch history가 지저분해지기 쉽습니다.

👉🏼 복잡한 프로젝트 history
독립된 브랜치에서 로직 하나를 작성하고 수정하더라도, 다른 작업과 그 내역이 겹쳐 구분하기 어려워집니다. 이런 상황을 프로젝트의
history가 복잡하다고 표현합니다.

2. git rebase main

  • Rebase는 내 commit의 base를 변경하여, commit history를 일렬로 잘 정리해줍니다.
  1. git checkout -b [브랜치명]
  2. git commit -m [커밋 메시지]
  3. git rebase -i main 로 commit rebase

s(squash) 로 log message를 정리

4. git push origin [브랜치명]

수정 작업 후
5. git add .
6. git commit -m [커밋 메시지]
7. git rebase -i main

  1. git push origin [브랜치명] -f

  • 해당 브랜치의 base commit을 확인하는 방법 : git merge-base main [브랜치명]
profile
꾸준하게 🐌

0개의 댓글