TIL42.Git flow with rebasing

조연정·2020년 11월 5일
0

commit내역을 깔끔하게 해주는 git rebase를 사용하고 익혀보자.

Git Rebase

기존에는 각 각의 브랜치를 합치기 위해서 'merge'를 사용해왔다. 하지만 merge외에도 브랜치를 합치는 방법으로 Git Rebase가 있다.
Rebase는 Merge와는 다르게 이름 그대로 브랜치의 공통 조상이 되는 base를 다른 브랜치의 커밋 지점으로 바꾸는 것이다.

git rebase의 흐름

git add -> git commit -> git checkout main(최신업그레이드를 확인하기 위해서) -> git pull origin main -> 작업한 feature로 이동 -> git reabase -i main -> git squash과정(pick s s) -> conflict 해결 -> git add -> git rebase --continue -> git push origin feature/브랜치이름 --force

* git squash

여러개의 커밋로그를 하나로 만들어주는 과정을 말한다.

pick 7c65355 Task 1
pick 2639543 Task 2
pick d442427 Task 3

# Rebase 2260a88..d442427 onto 2260a88
#
# 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's log message

//가장 위의 세줄을 다음과 같이 바꿔준다.

pick 7c65355 Task 1
s 2639543 Task 2
s d442427 Task 3

* git rebase --abort

리베이스가 완료되기 전에 리베이싱을 취소할 때, 사용한다.

profile
Lv.1🌷

0개의 댓글