When we rebase, we can end up with conflicts, just like when we merge.
We're combining history, we're combining branches together that can lead to a merge conflict.
So I'll just quickly demo that we are on the feature branch.
Let's change something on our website file.
How about I don't know, let's change this line that says Footer added Let's change it to say, What
should we do?
I don't know.
How about how about this instead of log in for me, do log out form added.
I don't know why you need a form to log out, but sure.
And then instead of nav bar added let's do top nav bar added.
Och not very exciting, but there we are.
So I'm going to add that and commit and let's just go, let's say like update website on feature branch.
I'm just putting on FT there so you can see it in the message.
You normally don't say what branch you're working on in a commit message, but I'm just doing that here
so that we can see it.
Now I'm going to switch to Master, right?
And I'll do some more work on one of these lines.
So instead of saying top nav bar, I'll say, I don't know, main nav bar.
And instead of log out, I'll do what should we say here?
Sign up form.
How about that sign up form added.
So we should have some conflicts, right?
And then we could even add something else.
Well let's start with that get commit dash am or on the master branch update copy on master.
So now I'm going to switch back to my feature branch.
Let's do a tiny bit more work.
Three.
Get commit a m.
Write more work on Ft.
All right.
So here's what our history looks like and get cracking.
So we have a divergence if that's the right way of saying that.
We have our feature branch, which has some work that's not a master, of course, quite a lot of work.
But then master has new work.
We'll pretend we pulled that down.
We didn't just type that ourself because I would be very stupid what I just showed you in the real world.
But whatever that work is, it's coming from GitHub.
We pull it down, it's new feature our collaborators added in.
I want that on feature.
So I'm on the feature branch.
I will rebase instead of merge, get rebase and then master.
And.
Oh, look at this output.
Slightly different.
Right.
So it tries it recreates all of our commits from the feature branch, rebasing them on the master branch.
But then it gets to this conflict.
Merge conflict in website text failed to merge and changes.
And if we look at our history.
Hmm.
Look at that.
It is a partial rebase if you can see.
I'll zoom in.
So we have the feature branch which is here and it started to recreate our commit.
So we have begin feature, but we also have begin feature.
We have work on feature and work on feature.
We have more work on feature, more work on feature.
So the rebase is not done.
So I have a couple of choices.
One, I can just abort the whole thing.
It tells me exactly what to do.
Here we are to abort and get back to the state before run, get rebase, dash, dash, abort.
But basically we are part of the way through rebasing.
So it made new commits, some new commits, but it had a conflict.
So we need to resolve that.
So it tells us in this case it's just one file website text.
I'll go in there and I have to decide what to keep, what not to keep, just like I would with any conflict,
a regular old merge conflict.
So what should I do here?
Let's say I want top nav far, but I want sign up form so I can just manually do this.
I'll do get rid of that.
I don't want main nav bar, I want top nav bar so I can just manually reconfigure.
I'm kind of just combining from two branches.
I could have just gone with one or the other, of course, and often that's what you do.
But in this case I'm going to manually just combine them so footer and then I want sign up form and
then image gallery as well.
All right.
So it's kind of a messy way of resolving it, but that is the new version of this file that I want.
Okay.
So now it tells me, hopefully you can see this.
What I need to do is mark them as resolved by adding them.
So get add the file and then run, get rebase, dash, dash, continue, make this larger.
So if I type get status it tells me rebase in progress.
Here's the commit that it's on.
It tells me exactly where it is in this rebasing.
So I'm going to add website because I fixed the conflict in there, but I'm not going to commit.
I'm going to run git, rebase, dash, dash, continue.
So this is where you want to just pay attention to the output, right?
We just follow the instructions.
It says all conflicts fixed.
Now run this or I can abort the entire rebase using dash dash abort if I just want to bail on it.
So right now rebase is paused, but.
I just continued.
It looks good.
Let's type get status.
All right.
We're going to re clean.
And now we successfully completed the rebase.
We resolve the conflicts, and the end result is that the changes from master and feature are all combined.
They're integrated.
So I have exactly what I wanted, right?
I have this file resolved the way it is and the entire feature branch.
All that history was rewritten on top of the master branch, rebased on top of the tip of the master
branch.
All righty.
So we still can have conflicts.
We're still just combining commits or combining branches, rather, and that can lead to conflicts.
The way you resolve them is the same.
You go into the files, it tells you exactly where the conflict is.
You pick what you want, incoming, original change or a hybrid of them like we did.
Then you add, you stage it, and then you follow the instructions.
In our case, we don't want to merge commits so we don't do get commits.
When we rebase.
We did get rebase, dash, dash, continue.
All right.