Using The Terminal

The first time I opened the terminal on my computer it seemed scary. We have all seen the above image of someones terminal and have wondered what they were doing. As I learned to code, I quickly realized that it would be necessary part of writing code, testing my code, and hopefully becoming a successful developer. There is a lot to learn about using the terminal, so I am going to let you in on some secrets of a few things that will make it easy to add files as well as how to push your code to GitHub, all using the terminal.
The following is what you will use to make a new folder within your terminal. For picking a name, lowercase and underscores are the best practice.
mkdir folder_nameSo, we made a folder, but now what do we do? The next thing we can do is get into the folder (or directory) so that we can put a file in it. We do this by doing the following:
cd folder_nameNow, we are in the folder and can add files to our folder. To add a file, we put in:
touch file_name.rbThis created a Ruby file, but we can end our file_name with whatever type of file we want to create. Now we have created a folder, gotten into the folder, and created a file within the folder all from our terminal! Not so scary after all.
Now, we will want to push all of this to GitHub from our terminal. That part requires some set up detailed here : https://help.github.com/articles/set-up-git/, but once you are done with that, we can move to the next step, adding our code to GitHub. Once you have used cd to get into your folder_name you want to initialize the folder. This tells GitHub, ‘Hey, I have this folder of code and want it to be stored’. Also, don’t forget to create a new repository on GitHub with the same name as your fine (so as not to confuse yourself) you will need this for the following commands to work. We initialize the folder by doing (you only have to do this the FIRST time you add a folder to GitHub:
git initYou can check your status at anytime. (Note: If the file name is red, it has not been added, but if it’s green, it’s ready to push up) To check the current status of our files we will do the following:
git statusYou will do the following to add all current files being within this folder to GitHub:
git add --allNext we commit the code to GitHub and add a message so that people who look at our code or work with you know what you did or changed! The -m is important, because if you forget it, it posts to your vim, which is a whole different discussion entirely. After that, we want to push the code to GitHub by using:
git commit -m "Here are the changes I made to my files and why"From there, all that is left is pushing the code to GitHub and we do this by doing the following:
git push origin masterAnd there you have it, your code is now on GitHub for the world to see! It seems scary at first, but once you do it every day, it quickly becomes second nature.