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

Enjoying Git

My current client uses an (onsite?) enterprise github thingy. We do basically branch-per-feature, which means a lot of merging.  And surprisingly few conflicts.   I find myself constantly going back to this graph:

image

It’s not available on the free public github, AFAIK.    You can see where people pulled from Refactor back into their feature branch, and how much context switching there is (we have two folks working on the project).

A video that really explained git to me was this:

[youtube=http://www.youtube.com/watch?v=1ffBJ4sVUb4&w=448&h=252&hd=1]
Awesome Git Video!

It highlighted the directed graph structure, and the role that nodes and labels play.  After watching it, I understood Fetch, Pull, Push, Add, etc – it all made sense! 

However, I’ll confess – I’m using tortoiseGit, not the git command line.