In this post, you’re going to learn how to create a repository and how to make it local on your computer.
Create a Repository
As mentioned before, a repository is a place to store all the stuff of your project. I said project, but it doesn’t mean that you have to build some big, work-related programs. You can see it as your playground, to try any code you’ve written, or to store exercise answers from your workbook. Whatever is fine.
After you created and verified your GitHub account, you will be navigated to a page to create your first repository. See the example below.
There, you need to input a name for your repository, set it public or private, and choose whether to create a README file, then click the green button, and you’re done.
As I said it before, it is recommended to make a README file. This file is to describe what your project is about. (I forgot to tick the README option before capturing the image. Please excuse me).
Clone a Repository
Now you have a repository, but it only exists in the web server. To make it local, you need to download it, or more precisely, to clone it.
On your computer, you create a folder into which you’re gonna to clone the repository. Then you open the command line (it is Terminal in my case). You need to navigate into that folder.
First, you type
ls, it will give you a list of your “folders”. If you want to “click” on a folder, type
For example, you created a folder named ‘demo’ on Desktop. Normally, you click on Desktop -> demo. In Terminal, you simply type.
(Sorry for talking too much. I got a hard time to understand what
cd are about, so I just want you to understand them easily)
So, you got to your favorite spot, it’s time to clone to it. You go into your repository on GitHub again, click on “Clone or download” (a green button), and copy the link (make sure that it says Clone with HTTPS). On Terminal, you type
$ git clone [link]
In my case:
$ git clone https://github.com/coding101-org/demo.git
The Terminal will run for some times. If you get the message ending like
Unpacking objects: 100% (3/3), done.
then you’re done. Now the repository on your online GitHub exists on your local computer too.
Branch is what make git different. A project contains one master and many, many branches that contribute to the master
For example, your main project is on master. If you want to make a modification, or add a new feature to your program, you make it on a branch. This branch needs to be implemented and tested. If everything’s ok, you can merge this branch to the master.
Congratulation! You’re 50% on the way. Next time, you will have a chance to know your command line buddy better.