Ruby on Rails – Git & Github

I’m just using this to document what I’m doing to help solidify the work in my head. I’m also likely to come back here to reference different steps…

To be able to back up and save your program, I’m going to use github.com. The first thing you have to do is set up your ssh (which stands for secure shell). You can use the command cat ~/.ssh/id_rsa.pub in the terminal. You then have to copy the code that is printed. Got to github, click to add a new SSH, and paste the code into the field. Once that is done, you should make a repository for each of the programs you will work on.

To create a new repository, you need to click on the “+” sign in the top right corner of github.com and choose “New repository”.  Name the repository something that makes sense (probably the name of your program).  You’ll then want to follow the instructions to “push an existing repository from the command line”.

Before you can actually “push” your changes to a repository with git, you have to “commit” the changes. git status can always show you what files have been modified. Use git add -A to add a file to your local repository (local repo). Then use git commit -m "note to remind you what this is for" to commit that local repo. This just “saves” your changes, but it hasn’t uploaded it to github. To “upload” it to github, use git push to push the files to github.

Right now, I’m able to fire up a rails server and see what I’ve created in my own browser, but that is all local, nothing to show others or see online.  If I want to be able to show it to others, I need to deploy to production.  I’ll be using Heroku (which is a very common site to use) for this.