Today started off with an introduction to Git, one of the most important tools of a web developer.
What is Git? Git is a version control system that is used for software development and other version control tasks. It was created by the genis Linus Torvalds in 2005.
Why use something like Git? Let’s say that you and someone else are both working on the same project and editing the same file at the same time. You make your changes, save them, and upload them back to the website. So far, so good. The problem comes when your fellow developer is working on the same page as you at the same time. One of you is about to have your work overwritten and erased.
A version control application like Git keeps that from happening. You and your coworker can each upload your revisions to the same page, and Git will save two copies. Later, you can merge your changes together without losing any work along the way. You can even revert to an earlier version at any time, because Git keeps a “snapshot” of every change ever made.
Some of the basic Git commands we learned are:
- git init – setup git in current directory
- git status
- git add . – adds files to staging area
- git branch [branch-name] – creates branch
- git checkout [branch-name] – change working branch to specified one
- git commit -m ‘message’ – creates a commit from staging, giving a commit message is mandatory
- git merge [branch-name] – merges specified branch into current
- git log – prints out a log of past commits
Frank! Did you Git it?
After getting used to Git, more or less as it was still quite hard for me to completely understand Git. We learned how to use our first Ruby framework, called Sinatra. Sinatra is a free and open source software web application library written in Ruby.
After making a “Tacta in Ruby” we redid the same Tacta but this time using the Sinatra framework. It was really cool to get an introduction to the MVC design pattern used in a lot of frameworks.
How does MVC work?
Model: The model represents the data, and does nothing else. The model does NOT depend on the controller or the view.
View: Displays the model data, and sends user actions (e.g. button clicks) to the controller.
Controller: Provides model data to the view, and interprets user actions such as button clicks. The controller depends on the view and the model.
Today was yet another great day, especially because we finally made our “first real website” thanks to Sinatra. Tomorrow we will get into Rails which is really exciting as it’s the most well known and used framework for Ruby.