|
Answer» Both these COMMANDS ensure that changes from one branch are integrated into another branch but in very different ways. Git rebasing can be thought of as saying to use another branch as a new base for the work. - Whenever in doubt, it is always preferred to use the git merge command.
Following are some factors that tell when to use merge and rebase commands: - In case our branch gets contributions from other developers outside the team as in open-source or public repositories, then rebase is not preferred.
- This is because rebase DESTROYS the branch and it results in broken and inconsistent repositories unless the git pull --rebase command is used. - Rebase is a very destructive operation. If not applied correctly, it results in loss of COMMITTED work which might result in breaking the consistency of other developer’s contribution to the repository.
- If the model of having branches per feature is followed, rebasing is not a good idea there because it keeps track of related commits done by the developers. But in case the team follows having branches per developer of the team, then the branch has no additional useful information to be conveyed. In this model, rebasing has no HARM and can be used.
- If there is any chance where there might be a necessity to revert a COMMIT to previous commits, then reverting a rebase would be almost impossible as the commit data would be destroyed. In such cases, the merge can be used.
|