Merge vs Rebase or a few words about hell

Merge vs Rebase or a few words about hell
Average rating: 0
(0 votes)

We have two main ways to incorporate our branches: merge or rebase.

Look at the picture, it is a basic example.

Снимок экрана 2016-07-30 в 11.03.35“HEAD” is linked to the last commit in the branch where we are.

MERGE

merge badDisadvantages of the merge:

  • Nonlinear history of commits
  • Works badly in big team
  • Create a new commit (merge commit)
  • The first commit for reset is  general commit

git co master & git merge feature

Снимок экрана 2016-07-30 в 11.17.17

 

What does merge do?

  • Finds general
  • Takes last changes from last commits in branches
  • Creates a new commit (merge commit)

The first commit for undoing changes is a general commit, and this is the main problem, in my opinion. However, we can return to the specific commit, but it is not very convenient.

 

REBASE

Advantages of rebase:

  • Conflicts occur less frequently
  • Conflicts occur for an each commit in particular
  • Clean history

features rabase master

Снимок экрана 2016-07-30 в 11.52.30

What does rebase do?

  1. Deletes commit in feature
  2. Changes parent commit to the last commit in master
  3. Copies all the changes into new commits with new parent

Then
git checkout master & git merge feature
Merge works with fast forward strategy in this case.

Снимок экрана 2016-07-30 в 11.58.31

GIT FLOW or the way I do it 

1 Create feature-branch from master
2 Do many small commits
3 Do rebase from master more frequently
4 Do rebase from master when work is done
5 Checkout in master
6 Do master merge feature-branch
7 Git push (First you have to finish the work, then you can push)
8 Delete feature-branch

Now you have a few thoughts about merge and rebase. If you are familiar with git, I advice you to use rebase.If you don`t know how it works, please use merge. Clean history is not really important if your project could be on fire 🙂

rebaseforce

Rate this article, if you like it

Thanks! You’ve rated this material!

Got a project? Let's discuss it!

*By submitting this form you agree with our Privacy Policy.

Mailing & Legal Address

Syndicode Inc. 340 S Lemon Ave #3299, Walnut CA, 91789, USA

Visiting & Headquarters address
Kyiv Sofiivska 1/2a, 01001, Kyiv, Ukraine
Dnipro Hlinky 2, of. 1003, 49000, Dnipro, Ukraine
Email info@syndicode.com
Phone (+1) 9035021111