This week, I’ve been working through some Code School video tutorials, including three on the topic of Git. Git is a software version control system. Github is an online repository hosting service (there are many out there) that works in conjunction with Git. While I’ve been using both for well over a year now, after working through some of the tutorials, I realized I hadn’t even begun to scratch the service of what Git can do.
One of the first nice things I learned was that “git pull” will fetch and merge changes, while “git fetch” will just fetch the changes and not merge. Another useful topic covered was branching. I had used branches before, but not really all that well. Branches allow you to work on a copy of the master code without worrying about mucking it up for anyone else. Then, once you’ve tested your branch code, you can merge it back into the master branch. I didn’t realize a branch could be deleted after being merged into master.
Another thing you can do with Git is push your code to multiple repositories, such as ones for test, staging, development, and production. Git also has a tagging feature, which can make it easier to find certain points in your code, such as tagging a commit with a new version number (i.e., pushing version 1.2). Lastly, I learned about “rebase”, which is useful when you want to make changes to previous commits.
I also started working on my second version of tic tac toe written in Ruby. My first version was written prior to starting here at SB and did not include any tests. The new version will have a full test suite written by the time I’m done with it.
My mentor told me yesterday that each file should have its own spec file (for instance, player.rb will have a player_spec.rb file). This saved me a lot of trouble because I would have tried to put all of my tests into one file! I defintely started to see some of the benefits of writing tests. First, it forced me to really think about what I was doing (including the design of my code), and second, I didn’t have to clutter my code with so many “puts” statements, or other garbage code that I used to write to “test” my applications.
I’m going to continue working on tic tac toe v.2, and hope to finish up the 3rd Git tutorial on Code School. I will also begin reading “Agile Web Development with Rails 4”. I’ve read the book before, so hopefully the second time around will help reinforce some of the things I’ve learned since the first time that I read it.