-
Notifications
You must be signed in to change notification settings - Fork 4
[Step 8] Avoid unnecessary merge with Rebase
This is a more an advanced topic. You don't use it day-to-day, but it is nice to know.
It is for moving the current feature branch to the latest parent branch.
so it would make this
become this
Here is a good reference if you decide to use this feature.
Explain Rebase vs Merge in 1 picture
-
Currently we have 2 branches from
master
. Checkoutmaster
branch and edit.gitignore
file and commit it asfix: update git ignore
. It would be like this if you use SourceTree to review the graph of branches. -
Checkout the test branch and right-click on the branch and click
Rebase Onto
-
In Onto branch, select master and click
Rebase
. Since there is no conflict, it will commit the changes right away. -
the history will be like this in Sourcetree. The current branch looks like just branched out from the latest master commit.
Note:
-
if there are conflicts, you can either merge or abort this operation.
command-line:
git rebase --abort
-
if the process is done, use
git reset --hard
to the commit before rebase. ref
The whole process
Back to HOME
-
General Operations
-
Advance Operations
-
Workflow