Saving your code to GitHub
You spent hours of your time writing code, editing, refactoring, and making sure its perfect. Or perhaps, you haven’t gotten to the final stage yet, but its a work in process. Now imagine your computer or breaks down. Or you delete the file by mistake. Or even more common, you overwrite the file with something else. Oh no! That stinks! Well, it doesn’t have to.
GitHub is a really cool site that allows you to save all your code to the web. It’s a really great way to make sure you never lose your hard work. It’s also a great method to be able to access all the various stages of your code, as well as show off your work for others to see.
Today, I will walk you through the process of getting your first code up to GitHub.
1: Open up your terminal, and go into the folder that you would like to save.
2: Type “git init” (this initializes the folder to be saved locally)
3: Type “git add — all” (git, then a space, add, another space, two dashes, and then all). This adds all the latest changes to be saved.
4: Type “git commit -m“write a message to name the memo”. This creates a message so that can later see what changes you made.
5: Go to https://github.com/ . If you don’t have an account yet, create a new account.
2: After creating or logging into your account, click on the + found in top right corner of screen.
3: Select “new repository”
4: Fill out the repository name with a name for your new repository. To keep things simple, its recommend to name it the same name as the folder on your computer.
5: Click on “Create repository”
6: Select the SSH option.
7:Copy the code shown on the page into the terminal, one line at a time.
8: Congratulations! You did it! Your file is now up on GitHub. You can go to your profile in your GitHub account, and the file will be there.
9: Now that the file is loaded to GitHub, its real easy to save all your latest changes. Simply go to the terminal and open the folder. Do step 3, and then step 4. Easy shmeezy, all your latest changes are now saved and viewable on GitHub.