Git Merge vs Rebase

An FAQ that explains and answers when to use which and why.

Cihat Gündüz
Nerd For Tech

--

There’s a common discussion among developers about how teams should use Git to make sure everyone is always up-to-date with the latest changes in the `main` branch. The typical situation this question arises is when someone worked on a new branch and then once the work is done and ready to be merged, the main branch had changes in the meantime in a way that the work branch is outdated and now has merge conflicts.

Obviously, they need to be resolved before the work branch can be merged. But the question is: How should this situation be resolved? Should we merge the main branch into the work branch? Or should we rebase the work branch onto the latest main branch?

In my opinion, there’s only one correct answer to this question. From my experience, the main reason why so many discussions arise around this topic is that there’s a lot of misunderstandings out there about how merge and rebase differ from each other in this context and a general lack of understanding, what a rebase even is.

So I created an FAQ for my team which tries to clarify things. Let me share:

What is a merge?

A commit, that combines all changes of a different branch into the current.

--

--

Cihat Gündüz
Nerd For Tech

📱Indie iOS Developer, 🎬Content Creator for 👨🏻‍💻Developers. Apps: RemafoX, Twoot it!. More in the works.