in Technology by

What’s the difference between rebase and merge? When should you rebase and when should you merge?

1 Answer

0 votes
by

Both rebase and merge commands are used to integrate changes from one branch to another but in a different manner.

As seen in the below two images, suppose you have commits (this is before merge/rebase). After the merge, you will get the result as a combination of commits. It binds together the histories of both the branches and creates a new ‘merge commit’ in the feature branch.

On the other hand, rebase will move the whole feature branch to begin at the tip of the master branch.

rebase and merge 300w" data-ll-status="loaded" style="border-style:initial; border-width:0px; height:auto; max-width:100%; width:525px" class="alignnone lazyloaded size-full wp-image-115468">

[image source]

Commits will look like:

commits 300w" data-ll-status="loaded" style="border-style:initial; border-width:0px; height:auto; max-width:100%; width:617px" class="alignnone lazyloaded size-full wp-image-115469">

Rebasing is not recommended for public branches as it creates inconsistent repositories. However, rebasing is a good option for private branches/individual developers. It is not very suitable for branch-per-feature mode. But if you have a branch-per-developer model, then rebasing is of no harm.

Also, rebase is a destructive operation, so your development team should be skilled enough to apply it correctly. Otherwise, committed work can be lost.

Furthermore, reverting a merge is easier than reverting a rebase. So, if you know that there can be possibilities for revert required, then you should use the merge.

Merge perseveres history as it is whereas rebase rewrites history. Thus, if you want to see the history completely as it occurred then you should use merge.

Related questions

0 votes
    What is the difference between Git Merge and Git Rebase?...
asked Oct 4, 2020 in Technology by Editorial Staff
0 votes
    What’s the difference between manual testing and automated testing?...
asked Jul 9, 2021 in Technology by JackTerrance
0 votes
    Name any one command that you can execute when it comes to viewing the exact difference between the repository and the local version?...
asked Feb 17, 2021 in Technology by JackTerrance
0 votes
    In SQL Server 2005, we can create temp tables one of two ways: declare @tmp table (Col1 int, Col2 ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 27, 2022 in Education by JackTerrance
0 votes
    I have been working on Power BI for a while now and I often get confused when I browse through help topics of ... two. Please guide me. Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    libsvm and liblinear are both software libraries that implement Support Vector Machines. What's the difference? And ... than libsvm? Select the correct answer from above options...
asked Jan 31, 2022 in Education by JackTerrance
0 votes
    What's the difference? What are the advantages/disadvantages of tuples/lists? Select the correct answer from above options...
asked Jan 30, 2022 in Education by JackTerrance
0 votes
    In my textbook I noticed that both these algorithms work almost exactly the same, I am trying to understand ... would be appreciated. Select the correct answer from above options...
asked Jan 26, 2022 in Education by JackTerrance
0 votes
    Are they same? In my view "hadoop fs" command shows the hdfs files and the "hdfs dfs" command shows the local files, why is that? Select the correct answer from above options...
asked Jan 21, 2022 in Education by JackTerrance
0 votes
    What's the main point of difference between human & machine intelligence? (a) human perceive everything as a pattern ... ) human have sense organs Please answer the above question....
asked Sep 21, 2022 in Education by JackTerrance
0 votes
    Why Both Numpy.linalg And Scipy.linalg? What’s The Difference?...
asked Apr 25, 2021 in Technology by JackTerrance
0 votes
    What is the difference between Hibernate and EJB 3? Do not you think EJB 3 is just a clone of Hibernate?...
asked Jun 5, 2021 in Technology by JackTerrance
0 votes
    Can you explain the difference between direct and alternating current?...
asked Dec 12, 2020 in Technology by JackTerrance
0 votes
    When using the SOAP API to work with salesforce.com (SFDC) it seems that the primary key in the underlying database ... is all about? Select the correct answer from above options...
asked Feb 2, 2022 in Education by JackTerrance
0 votes
    Let X represent the difference between the number of heads and the number of tails obtained when a coin is tossed 6 ... values of X? Select the correct answer from above options...
asked Nov 25, 2021 in Education by JackTerrance
...