Saturday, March 23, 2013

rewriting history 1


As I said before, I'm coding in Ruby as I follow through Kent's book. Whenever I start a new chapter, I commit the code. If I want to start over the chapter I'm in, I just revert my changes. I haven't discovered how I would revert my code to an old commit yet (for instance, if I wanted to work through the second chapter again), but I'm pretty sure there is a way.

Between chapters 14 and 15, I made some minor changes to the code. My history was something like this:

commit - going to chapter 14
commit - minor changes
commit - minor changes
commit - deleted file
commit - going to chapter 15

I wanted to go back to chapter 14, but I didn't want to lose the minor corrections I did before chapter 15. I was wondering if there was a way of merging multiple commits, and after some googling, I've found this article. It is possible and very easy to do. I've merged my commits and now the repo is just like I wanted.

I think git will never cease to amaze me.

1 comment:

  1. Two years ago Akita did an "intro" to git that turned out to be three hours long... http://vimeo.com/15146453

    Worth every second of your time.

    ReplyDelete