Version Control (feat. SSH)

  1. GitHub
  2. Repository SSH Access

 


 

The last thing to discuss before we actually get to do something in Rails is version control. This might seem largely unnecessary within the remit of learning how to code with Rails, but using it while learning the rest of this stuff will pay off when you start writing your own apps without the help of this wonderful guide. When we come to deploy our app later on, you will also be glad you did this from the start!

While other version control systems are available, this guide will focus on using git and its companion repository store, GitHub. Git does all the tricky bits of version control for you, so all you have to do is make sure you are pointing at the correct repo(sitory) and the right branch, and that you actually push your work to the repo! Git supports a number of repository stores, my particular favorite being GitHub which gives you unlimited free public repositories (and unlimited private ones for a very reasonable monthly fee).

To get started, head over to GitHub and set up your free account (will require email verification).

GitHub Home

Once complete, hit the + sign on the top-right of the interface and create a new repository with a name of your choosing.

GitHub New Repo

Once done, this will give you a page of instructions on how to initialise a repo and push it to GitHub, which we will go through later.

 


 

In order to push our files, we will need to set up SSH access to the machine we will be developing on. GitHub will soon be removing the ability to authenticate yourself using your account login credentials, so it makes sense to start as we will have to go on. If you are using an online IDE or a Google-hosted VM then SSH access should already be set up for you - if not, you only need to install an SSH client and generate a key:

$ sudo apt install openssh-client          ## install the client
$ ssh-keygen -t rsa                        ## generate your key
## Just hit enter until you get your beautiful randomart image

With our SSH key generated, either by the host or by us, we can run the following to show our public SSH key:

$ cat ~/.ssh/id_rsa.pub

And now we just paste this key into the Key Settings in your GitHub account settings under New SSH key, giving it a snappy title.
With this, we are ready to push our app to GitHub securely and easily. But first we need to build the app!

 
 

Comments

Popular posts from this blog

New Rails Apps with Docker Compose

[ToDoList] Basic Pages

[ToDoList] Docker Compose