About this lesson
Download this lesson’s exercise file.Backup Your Code Using Github.com.docx
Backup Your Code Using Github.com
Github.com allows us to save our version controlled code on a third party website for safe keeping.
When to use
Any time you make significant changes to your code, you should save it using version control and git. Since git sits on your local development environment, it's a good idea to push your code to a third party for safe keeping in case your local environment ever crashes. We'll use github for that.
Sign up for a free account at GitHub.com
Next, copy your C9 ssh key by issuing this command in the terminal:
- cat ~/.ssh/id_rsa.pub
Copy and paste the whole block of text from the terminal, then log into your github.com account and click the "setting" icon in the top right corner of the screen. Next, click the "SSH and GPG keys" link on the left side of the screen. Finally, click the "New SSH Key" button at the top of the screen.
Name your key anything you like, then paste the ssh key into the text box provided. Click the "Add SSH Key" button to save your key.
Next; we need to create a new repository. Click the "Your Profile" link at the top right of the screen. Next, click the "Repositories" link at the top of the screen, then the "New" button.
Name the repository anything you like (pinteresting), and click "Public" then click the "Create Repository" button.
Github.com will provide you with two commands to enter into your C9 development environment, that should look like this:
- git remote add origin email@example.com:username/ProjectName.git
- git push -u origin master
From then on, whenever you want to push code to github.com use these three commands from the terminal:
- git add .
- git commit -am 'commit message'
- git push
Hints & tips
- github.com offers free public code repositories
- github.com makes you pay to keep code private
- once you connect to github.com once, you can push code from then on with the "git push" command
- you don't need to log into github.com every time you write code
Lesson notes are only available for subscribers.