Merge vs Rebase or a few words about hell

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

Thanks! You’ve rated this material!

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 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.



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

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 🙂


Rate this article, if you like it

Thanks! You’ve rated this material!

Got a project? Let's discuss it!

    Kyiv Sofiivska 1/2a, 01001, Kyiv, Ukraine
    Dnipro Hlinky 2, of. 1003, 49000, Dnipro, Ukraine
    Kharkiv Otakara Yarosha 22, 61000, Kharkiv, Ukraine