Open In App
Related Articles

How to Push Anything to GitHub using Git Bash?

Improve Article
Save Article
Like Article

For a beginner, it is a very hectic task to make a GitHub repository and push anything on GitHub, for this we all have seen a lot of videos but it is very time-consuming. So in this article, we are going to see how you can push whatever you want to push on GitHub. So let’s start.

Prerequisite: Must have a GitHub account and git bash installed.

Step By Step Implementation

Make a GitHub repository by clicking on the “new“ Button.


Now after clicking on that you will see a screen something like as show below in the image.


Give the name of your repository and give a short description of your repository.


After that just click on the “create repository “ option.


After that, your repository has been created successfully.


Now go to the local folder that you want to push on GitHub and after a right click a menu will show in which you have to click on “Git bash here”.


After that GitBash will open and now you have to make a clone of the repository that we have just made. We can make the clone by simply writing the command “git clone https://link”. This https link we will get from our repository.

How to get this https:// link??

Just go to your repository and there is an option name “Code” just click on that and how you are able to see the https:// link so just copy that.


Now we are having the link to go back to the GitBash terminal and type “git clone https://link” and hit enter.


Now go to that local folder and you will find a new folder that is the same as our repo name.


Now Just copy these files and paste them inside this demo_repository folder.


Just go to your GitBash terminal and write “ls” and hit enter this command will show all the files that are present inside that folder.


Now we have to go inside this Demo_repository folder so this we can write “cd folder name”.


Now again we can write the ‘ls’ command to see what is inside the folder.


There is a command “git status” this shows the status. Whatever the changes we made in this folder and after that we execute this command then this will show us all the changes in red color.


So to add these changes we will write the command “git add -A” by this whatever the changes we have made at once added to the stitched area means now if we run the git status command all files are shown in green color.


Now it is time to commit these changes we can do this by the command “git commit -m “a valid message ””.


If we run the git status command it will show something like.


This is the last step now write the command “git push origin main” and hit enter.


Now go to your repository and there you will find all the files that you have pushed.


Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 27 Mar, 2023
Like Article
Save Article
Similar Reads