GitHub - Creating First Repo
Tags: github, git
Published: 2022-05-29 08:02:59

So, we have learned Basics of:
- [Version Control System](https://article.hasabtech.com/versioncontrolsystem/Git-What-actually-is-VCS)

- [Git](https://article.hasabtech.com/versioncontrolsystem/Git-Basics-In-Nutshell)

- [Setting Up GitHub.](https://article.hasabtech.com/versioncontrolsystem/GitHub-Setup)

Time to move on and create our first repository on GitHub.

## Creating First Repository on GitHub

Navigate to **Repositories** and click on **New**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vtw5xyqpyiv5b7n1gtuz.png)

Fill out basic info:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2aw2piu8d4zrl0aaezyo.png)
  
These two are compulsory:
- Repository Name
- Selection of Public and Private

Public Repository is seen by everyone where as Private Repository is only visible to you.

Once you are done, click on **Create Repository**:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dp89ek8ym33cbi14oxr2.png)

## Options in Creating Repository



Generally you are provided with three options.

**Option 1** is used when you want to begin from scratch

**Option 2** means that you are already working and just want to push the project on GitHub

**Option 3** means to import a repository from somewhere else.

## Create New Repository in CLI

You just need to enter the following commands as shown in option 1 in Git Bash.
 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dhclm48bnrl6dbkslptr.png)

Most of the commands have already been studied in our article where we got out basics of Git straight.

Lets rewind them a bit..


1. `echo "# test-repo" >> README.md`
This **creates `README.md`** file in the folder/directory you are present in and **save `"# test-repo"` as its contents** in the file.

2. `git init`
This **initializes** the git repository in folder/directory you are present int.

3. `git add README.md`
README.md file which was created as a result of first command is now added to *Staging Area*

4. `git commit -m "first commit"`

This `commits the changes` with the message `first commit`.

5. `git branch -M main`
This `creates a branch` called as `main`.
Note: We are always working in a branch; default branch is main.

So far, we have done stuff that we already knew. Time to move on to the remote commands.

6. `git remote add origin https://github.com/shameeluddin/test-repo.git`

This creates a pointer.
Key of pointer is `origin`
Value of pointer is `https://github.com/shameeluddin/test-repo.git`

One of the benefits the key origin provides, is that, you do not have to memorize the whole URL, you can just use the short name.

You can name anything other than *origin* but this is a conventional and/or standard way so just go with the flow because if you move away from conventions/standards, it'll be difficult for others to maintain/upgrade/fix your projects.

Similarly, you can add as many pointers as you want.
You can download project/changes from one (remote location) pointer and push it to another pointer (remote location)

You can find out about remotes with `git remove -v` command:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8r1ejthnav33u8y7th4s.png)
 

6. `git push -u origin main`
This command **pushes (uploads)** changes to **origin** which are present in **main** branch.

### Pushing Changes First Time 
If you are pushing changes first time then you will be required to log in.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eig0hf3xt6jpzavxiorg.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ef7r3xetmr5xwt0gfqiy.png)
Do not worry about this step, because, you need to authenticate that you have the rights to push changes to the selected repository.
  

## Result

This is what you see in your CLI after you have successfully authenticated yourself and pushed the changes.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k47vh2nzthrpzdefu8rx.png)

Refresh the page on GitHub.

This is what you see on your GitHub repo page:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/obres0gcp1tof72c5203.png)

That's it folks!

Lets meet again and discuss most important remote git commands for daily usage.