Git merge versus rebase

when we want to integrate changes from one branch into another branch, we basically have two options available. Both merge and rebase can do this job.

On overview of the differences between the two options can show us when to opt for merge or rebase according to your need or preference.

Merge Rebase
One step operation to resolve your conflicts Multi step operation to resolve your conflicts
Code history becomes intensely polluted Code history remains flat and readable
Traceability Rewrites commit history

Git merge

One step operation to integrate the latest changes into your branch. You will need to resolve all conflicts in one step. Can be sometimes hard because you lack information on what happend in between. By doing a merge, you keep traceability at all time. You will seen when the latest code was integrated in the branch. Downside here is the pollution of the git history.

Git rebase

Multi step operation to resolve conflicts. When you work in a structured way with small commits, you have each time the needed context to apply your changes on to the latest development. Most of the time, conflict free rebase is possible and you will end up with a clean git history.

I discovered rebase only six months ago and after intensive use on daily basis I can only regret that I did not use this command before. It helps me to work in a more structured way.

Conclusion

Both commands can do the job, so try to use them for your own benefit!