git MERGE vs REBASE

Couch Potato·2020년 9월 1일
0

git

목록 보기
1/1
post-thumbnail

Exercise

  • want to merge m3 and f2
  • there are 2 ways -> MERGE and REBASE

1) MERGE

  • git checkout master
  • git log (shows commit message "m3" as latest commit)

1. git merge feature


OR

2. git merge --squash feature 
  • summarize all the changes in the feature branch
  • git push (MUST DO FOR UPDATE! remote -> origin)

2) REBASE

1. FEATURE BRANCH

  • git checkout feature

  • git log
    - feature branch m2-> f1

  • git rebase master

  • git log
    - m2 -> m3 -> f1

  • git checkout master
    - m1 -> m2 -> m3!

  • Find and saves internally
  • After rebase, the feature branch are rebased on m2, not m2

2. MASTER BRANCH

(branch - added committed "f2" in the feature branch)

  • git rebase feature
    - see the latest commit
  • git log
    - m1 -> m2 -> m3 -> f1 -> f2
  • Do not rebase commits that exist outside your repository
  • Rebase는 로컬 레포지토리에서만, 큰 프로젝트에서 rebase를 사용하면 위험!

0개의 댓글