GitHub Repository creation + Adding files through Git Bash Terminal

Hello everyone, I'am going to show you how to create a basic GitHub Repository and add your files to the created Repository using the Git Bash terminal.

First you must create an account at the GitHub website.Once you have created the account in the left you will see the repository section.Now Click on the button called new in that section.This will take you to the repository creation page.



Now simply enter any name you want and choose the type(public or private) and click on Create repository button.If you go to the homepage now you will see the newly created repository in the repository section.Okay,now that we have created a repository lets see how we can add files to it.

First you need to download and install Git Bash.(https://git-scm.com/downloads).Once you have installed it open the Git Bash terminal using the start menu.Now there are a few commands you need to input into the terminal.So now I will show you step by step the commands you have to input.

First what you have to do is change your current directory to the one you need to upload files from.
Now lets say what I want to upload is in C drive in a folder called projects, So to change your directory into projects folder type in,

1. cd C:\projects and press enter

Now type in "ls" and press enter.This command will show you the files in the current directory so it will help you to check whether you are in the right folder.

 
Important note - If this is the first time using Git Bash you might be prompted to log in to your Git                                 Hub account at some point.If this is the case please follow the instructions given                                   and login to your account and  you will be able proceed with this process.

2. git init -- this command will initialize the current local directory as a local git repository.
3. git remote add origin _______________(your repository link)  -- This command sets the new remote.
 
You can also type in-- git remote -v  --at this point to check whether its working.


It should display push and fetch options as displayed above.

4. git add . - adds the files in the local repository and stages them for commit.
5. git commit -m "______"(commit name) - This command will track any new files that have been added to the local repository and get them ready to be pushed to the remote repository.


6. git push origin master - This command pushes the changes made in master directory to origin.This is where the files actually get updated in the GitHub website.


That is it guys! now refresh your repository and your folders and files should be there.I hope this blog was helpful!   

Comments

Popular posts from this blog

What is a Callback? - JavaScript

Difference between var,const and let in JavaScript

Introduction to NODE.JS