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

[image source]

Commits will look like:

commits

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 SDK and Runtime in .NET Core?...
asked Feb 16, 2023 in Technology by JackTerrance
0 votes
    What’s the difference between manual testing and automated testing?...
asked Jul 9, 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
    How can I continue this rebase allowing unrelated histories with the forced flag introduced in the new release?...
asked Jan 8, 2021 in Technology by JackTerrance
0 votes
    Does anybody know how to easily undo a git rebase? The only way that comes to mind is to go at it manually: ... replayed. Not only one. Select the correct answer from above options...
asked Feb 1, 2022 in Education 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
    // merge.cpp // merges two containers into a third #include #include //for merge() using namespace std; int src1[] = { 2, 3, 4, ... , src1+5, src2, src2+3, dest); for(int j=0; j...
asked Jun 2, 2022 in Education by JackTerrance
0 votes
    How will you merge elements in a sequence?...
asked Nov 25, 2020 in Technology by JackTerrance
...