Upload files in GitHub using Git Bash Terminal (Creating Basic Repository and Adding Files)

As we all know, GitHub is a wonderful platform where you can share, discover and build various software. So in this blog, I will be discussing in detail about creating a basic repository and adding files in the repository.

Pre-requisitions before using Git Bash Terminal

Before you use Git Bash, make sure you have your GitHub account so that you can create your repository there then upload and view your files. In case you do not have an account, you can follow the link to know the detailed procedure for creating a GitHub account as below.

https://medium.com/@hrishav.tandukar/how-to-create-a-github-account-21879376c8ab

If you have a GitHub account, you are required to install Git in your PC in order to implement all the steps ahead. So, if it is not downloaded and installed in your PC yet, visit the link below to get it installed with proper guidance.

https://medium.com/@hrishav.tandukar/how-to-download-install-git-for-windows-23ae8c12c5c7

Procedure for uploading files in GitHub using Git Bash Terminal

Step 1: To create a new repository, first, go to the top right of the menu bar in your GitHub account. Here, you must see a “+” sign. You can now click on it and select the first option of drop-down list i.e. “New repository”

Step 2: Now, you should give a name for the repository, for now I have named the repository as sample_template. Then, select “Public” option if you want to allow everyone to view what you have uploaded in repository whereas you need to select “Private” option if you want to choose the individuals who are allowed to view this repository. Then, check “Initialize this repository with a README” in case if you want to immediately clone the repository to your PC. Then, click on “Create repository” button.

Image for post
Image for post

Step 3: If you are redirected to page as shown in the image below then, your repository has been created successfully.

Image for post
Image for post

Step 4: Now, open the file which you want to upload in GitHub.

Image for post
Image for post

Step 5: Right click on file explorer in which the files that are to be uploaded opened, then click on “Git Bash Here” as shown in image below.

Image for post
Image for post

Step 6: ‘cd’ command is used in order to go to certain files. Since, we have already reached the destination which comprises of all the files that are to be uploaded in GitHub, we will not be executing the cd command.

Image for post
Image for post

Step 7: ‘ls’ command is used in order to view the files that are present in that directory. The purpose of ls command can be clear after viewing it’s implementation which has been shown in the image below.

Image for post
Image for post

Step 8: Enter command as ‘’git init”, in order to initialize an empty git repository. So, what this basically does it that it prepares your directory to be uploaded.

Image for post
Image for post

Step 9: Now, go to your repository and copy the HTTPS link which has been shown in the image below. Then, go back to Git Bash.

Image for post
Image for post

Step 10: Provide command as “git remote add origin “ then paste the HTTPS link of your repository. git remote add origin is used to add a new remote.

Image for post
Image for post

Step 11: Enter command as “git remote -v” to check if fetching and pushing is working or not.

Image for post
Image for post

Step 12: Give command as “git add .” to take all files from your directory and push it to your repository.

Image for post
Image for post

Step 13: Provide command as “git commit -m “First commit” ” to make the first commit in the GitHub repository.

Image for post
Image for post

Step 14: Finally, enter command as “git push origin master” to push the master directory to the origin.

Image for post
Image for post

Step 15: Now, go to your GitHub repository and refresh the link. In the repository, you can now see that all the files have been uploaded.

Image for post
Image for post

If you want a sample template of the website to practice the tasks, then the link has been attached below.

Also, in order to view the contents regarding various services of AWS you can visit the link provided below:

www.positivestud.com

Written by

Cloud Computing | Data Science | Mobile Application Development | Artificial Intelligence | Python Programming | Soft Skills | Many more…

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store