In this quick Git tutorial video, we’ll answer the question, “What’s the difference between merging and rebasing in Git?”
Watch now to:
- See a visual explanation of merging and rebasing
- Find out when you should use merging vs rebasing
- Learn how to merge and rebase using GitKraken
Merging vs Rebasing
Merging is useful for combining changes from one branch into another, and for preserving history.
Say we have a
Master branch with changes. Then, we branch off into a
Feature branch and make additional changes.
If we merge changes from
Feature over to
Master, all changes from the
Feature branch will be added to
Master. This gives us an accurate representation of the history, in addition to getting all the changes combined onto
However, if we have multiple branches, the graph becomes more difficult to read when all the branches are merged.
This is where rebasing serves as a useful alternative for a cleaner graph. Rebasing takes the commits from a branch and places them onto another branch. This changes the tree structure by moving the commits and their changes onto the target branch.
When comparing merging and rebasing…
- Creates a cleaner history
- More readable graph
- Tougher to resolve conflicts
- Preserves history
- Easier to resolve conflicts
- Easier to undo if you make a mistake
If in doubt of which to use, we recommend merging your changes instead of rebasing.
Watch the video to see how merging and rebasing work in GitKraken. It’s pretty much as easy as dragging and dropping!
Thanks for checking out the latest tutorial video in our Learning Git with GitKraken series.
Stay on the cutting edge of software development by getting innovative tips, trends and stories delivered to your inbox every month!