git rebase

I’ve never done a rebase before.  I figured today would be a good day to try it out.   It’s a simple case —

imageimage

From the client’s point of view, origin/master is ahead by one commit.   It happens to be a conflicting change.

In Tortoise (I’m starting out easy), I pick “Rebase”, and I’m saying I want to change my branch SG-EndToEndTest to be “re-based on” remote master.

image

  • Its showing me the list of commits that I’ve had, since I started my branch from wherever
  • Everything is picked.  Could choose to not-pick some stuff, leave it behind, like config file changes for local debugging.

I click “Start Rebase”.  It starts from the bottom of the list (ID=1) above and triest to re-apply the commits to the new root.   It runs into conflicts –

image

I right click on the conflict, edit it .. turns out TortoiseDiff doesn’t think it’s a conflict, I can easily mark it as resolved.  I have to do this twice, both in .csproj files.

When its done, its all still local – server’s not any different – but local shows:

image

  • The old commits are still there.
  • But they’ve been cloned and re-grafted onto a new source node, and the label has been moved.
  • If I had to, I could undo everything by force-moving SG-EndToEndTest to be based on ad1c.

If I now push up to the server – I get an error:

image

Instead, I have to push with –force (“may discard unknown changes”) (ie, “tell the server to do stuff where it discards changes that I, the client, know nothing about – JUST MOVE THE REF”)

image

Now the server looks like this:

image

That was my first, very simple, rebase (without squashing).

The pull request that I had open against that branch survived as well, and changed from “Cannot merge – conflicts” to “Can merge automatically”:

image

Author: sunnywiz

Me.

Leave a Reply

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