Git Rebase vs. Git Merge

Git Rebase vs. Git Merge

1.VCSs are essential and used to support the release of a completed software to the customer. The most famous VCS is git. Your manager has invited you to participate in a crucial decision-making meeting. He would like to know in detail what kind of git strategy to use to ensure enough information is captured to support the release of the new version of software to be developed.

Feature branching strategy – the main branch is protected. If anybody wants to make any changes to the code base in the main branch that is running production, he or she must use an unprotected branch, which requires the creation of the pull request that must be approved for a successful merge to happen.

2.The history of the commit is vital, and the manager would like to have an organized linear history of all the commits to ensure the new version of the software will be easy to release. Would you advise the manager to use git rebase or git merge, and why? (Do not forget to include the advantages and disadvantages of both methods)


Git Rebase vs. Git Merge


Two branches are displayed in the image below. Namely, the main branch and the feature branch called Jessica.

The main branch has 4 commits labeled M-1, M-2, M-3 & M-4. The feature branch Jessica has 4 commits labeled F-1, F-2, F-3 & F-4.

Git Merge and Git Rebase commands are used to combine the work of multiple developers in one code.

The end objective for both these commands is the same, but their usage varies.

Git Rebase comes from joining two words. Re + Base = Rebase

Git Rebase is like git merge, but the logs are modified (rewritten). Git rebase was introduced to overcome the limitation of merging, i.e., to make repository history logs look linear, as shown in the image below

Advantages:

• The logs are linear

• It is easy to move through the project.

Disadvantages:

• We cannot track, when and how the commits were merged on the target branch because the history is usually rewritten.

Git Merge

Git merge will combine multiple sequences of commits into one unified history. In the frequent use cases, git merge is used to combine two branches as shown in the image below.

Merge commits are unique against other commits in the fact that they have two parent commits. When creating a merge commit Git will attempt to merge the separate histories auto magically for you.

Advantages:

  • The logs are very exhaustive and can help in understanding the complete history of how and when each merge happened.
  • It is easy to find mistakes and resolve them.

Disadvantages:

• Results in a clumsy log/history

• Not very user-friendly

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top