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.
Step 2: I will create a new repository on github named "push_to_github", and click create without checking any other options.
Step 3: I will right-click on my "push_to_github" on my Desktop and click on Git Bash Here
Step 4: On my git bash, I will do the following:
git init
git add
git commit -m "First commit"
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 (github.com/vincentiroleh/push_to_github) and back to my git bash I will execute the following commands:
git remote add origin https://github.com/vincentiroleh/push_to_github
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 https://github.com/vincentiroleh/push_to_github
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. ๐