Git and Github

Create GitHub Repository And Add Files using Command Line

Create Git Repository and upload git repository to Github

In the previous Git tutorials, we have seen that how we can initialize the Git repository, create branches revert changes, etc. Now in this GitHub tutorial, we will learn that how we can create a GitHub account and connect local Git account to GitHub account. We will also see that how we can Create GitHub Repository locally upload the project to GitHub using Git.

Introduction to GitHub:

We have already discussed in detail about Git in the previous tutorials, so Git is basically an open source version control system which is designed to organize and manage small and large every type of project with speed and efficiency.

While the GitHub is a web-based hosting platform for individuals and teams to store Git repository. GitHub is built on top of Git and it allows you to have both local and remote copies of your projects. With GitHub, you can easily share your project with anyone when it’s in the development stage. You can explore different popular project and can implement the new feature in their repositories.

Creating a GitHub Account:

Create a Github Account

The first thing we need to do is go to the official site of GitHub and get an account. Simple click on the top Sign up button and then fill the form to create a personal account. On choose your plan screen to select the “Unlimited public repositories for free” and click continue button. Now after finishing signing up process, you need to verify your email address by logging into your email account that GitHub sent you.

Create GitHub Repository:

To create a new repository, click on the + plus sign which is on the top right corner and then write the required description in the form. Here is the demonstration below:

How to Create Github Repository

Now after filling up the form click on the Create Repository button.

Connect the Git Repository to GitHub:

We have my repository created, now we download that repository using the terminal. Open your terminal and write the following clone command which clones a repository into the newly created directory.

>git clone <URL of the Repository>

In our case, the command will be:

>git clone

Now add some file in that directory, in our case we have added three text files with some text. The first thing we will do is check the status and then we add those files for commit after commit those files we will push that files to our GitHub repository.

To add the changes in the working directory to the staging area write

>git add .

And to check the status of Git repository write:

>git status

TO commit all the files write the following code in the command prompt.

>git commit -m “All files Committed”

Upload a git repository to github

Upload your code to GitHub Using Command Prompt:

Now to push your repository to GitHub write the following command on your terminal:

>git push

It will open up a login window, now write your GitHub login username and password. Here is the demonstration below

github Login

Click on login button, it will upload all your files in the GitHub repository.

Git Push - Upload git repository to GitHub

Here is our command prompt window where you can notice that it has added all the files to GitHub. Now open up your GitHub repository and where you will see all your files. Here is the screenshot of your GitHub repository.

GitHub Repository

In this GitHub tutorials, we have given the introduction to Git and GitHub. And we have seen that how we can create GitHub repository and clone that Git repository in the specific folder. We have also learned about how we can upload files to GitHub.

Click to comment

Most Popular

To Top