Version Control with Git
Before diving deeper into SQL, I thought it might be prudent to talk about version control and how to get help on line when you get stuck. This tutorial is going to provide guidance on how to get set up with version control using Github. The following tutorial after this one will be on how to get help online when you get stuck. After that, we'll get back onto the SQL series.
If you already have Git installed and set up, hang in there. I need to make sure that all the basics are covered. Another great resource to learn more about Git and how to set up your development environment is at the Learn Enough Society.
Version control enables developers to record changes made to scripts, files, and folders while developing applications. After saving her work, the developer can then revert back to previous versions if and when the need arises. While developing applications, the developer, might have a compelling reason to revert to an older version of her code. This is where version control comes to the rescue.
Instead of undoing or retyping everything back to the old version, she can simply run a few commands in her terminal and boom, her version from yesterday is back to where it was. If she loses her files, she can easily recover them using remote repositories such as Github, Bitbucket, etc. The developer can also compare changes to her work over time. If she's working with a team, version control allows her to track what changes were made, who made the changes and when any such changes were made.
It's important to have some form of version control set up when one starts building his application. There are many books that have been written on version control tools and my favorite one is Git. To learn more about Git click here. If you're not yet ready for a deep dive or getting lost in that forest, read on.
The purpose of this tutorial to help you avoid the Git forest and to get your development environment set up with Git and Github version control.
1.Register for a free account with Github and make note of your email, password, and username. You'll need these shortly.
2.Check to see if Git is already installed. If you don't have git installed, you can follow the instructions below for a Mac or Linux operating systems such as Ubuntu or Debian. An alternative way to install Git, as well as Ruby and Ruby on Rails, is to use the RailsInstaller web application. Here you can select your operating systems such as
Linux. From there, everything is self-explanatory. If you're up for a bit of a challenge follow the tutorial below.
$ git --version
3.For Mac Users: You should see something like the line shown below. If you don't see this, then you need to install Git. Your version number might be different from mine. Also, note the line below is not a command. One hint would be the absence of the
$ sign. This is a convention I'll follow in all my tutorials.
$ means you an run the command in your terminal and if there's no
$ sign then it's most likely going to be a value returned in the terminal from the previous command. So don't run next line, it's just a returned value.
git version 2.17.1 (Apple Git-112)
4.If you don't already have homebrew installed run the line below to install it.
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
5.If you're curious, learn more about the command
$ brew doctor --help
6.Check your system for potential problems.
$ brew doctor
- Install Git
$ brew install git
If you're on a Linux based system, e.g. Ubuntu or Debian you can install Git using the following lines below.
1.Check to see if you have Git installed already.
$ git --version
2.Update your system
$ sudo apt-get update
$ sudo apt-get install git
Finally connect your Gihub account to your computer by running the following lines. This applies to all systems
1.Add your username
$ git config --global user.name "YOUR NAME"
2.Add your email address
$ git config --global user.email "YOUR@EMAIL.com"
3.Generate your SSH Key
$ ssh-keygen -t rsa -C "YOUR@EMAIL.com"
4.Run the command below, to copy your public key.
$ pbcopy < ~/.ssh/id_rsa.pub
5.Next, visit Github and add your
SSH Key by pasting what you copied from the previous command above. Use the link provided below to get to the Github SSH Keys page.
6.Go back to your terminal and check to see if everything is set up correctly by running the command below.
$ ssh -T firstname.lastname@example.org
7.If all went well, you should see the following output shown below in your terminal.
$ Hi YourGithubUserName! You've successfully authenticated, but GitHub does not provide shell access.