GitHub -Push from local to remote (Step-by-step)

GitHub -Push from local to remote (Step-by-step)


0 min read

This post is intended for everyone learning Git and GitHub for the first time, and asking how to push your project from your local machine to GitHub.

I will assume I am talking to myself while doing this tutorial, so follow along and talk to your self as well. ๐Ÿ˜

Step 1: I will create a new folder on my local machine called "push_to_github" with two files inside "index.html" and "app.js" and some simple code in both of them.

Screenshot (2).png

Step 2: I will create a new repository on github named "push_to_github", and click create without checking any other options.

Create a New Repository.png

Step 3: I will right-click on my "push_to_github" on my Desktop and click on Git Bash Here

Screenshot  (3).png

Step 4: On my git bash, I will do the following:

git init
git add
git commit -m "First commit"

Screenshot  4 .png

In the above code snippet, I initialized my folder with git, then added every file on track and finally committed them.

Step 5: Next is to go back to my GitHub (the repo we created early) and copy the URL of my repo which looks like this ( and back to my git bash I will execute the following commands:

git remote add origin
git push origin master

If you encountered an error: fatal: protocol 'https' is not supported

To resolve this, execute this command below:

 git remote set-url origin

Then try:

git push origin master

In the above code snippet, I connected the remote repo to track the local one, and then pushed my changes to the remote repo.

If the https error occurred while doing that, we set our url again, and everything works just fine.

Thank you

I hope I helped you solved a problem, do share and comment if you need my assistance. ๐Ÿ’•