Create a folder
Open the VS code and open the terminal
locate and open the file created in Step 1
Create a file and add contents to it.
open Git Hub
Create a repository (You will see a
+
mark in the top right side), and choose whether your repository should be public - accessed by everyone or private - select accounts that you want to grant access to.open terminal inside VS code
Locate the file which you want to upload to GitHub via terminal, and see if the terminal is opened for the folder that you want to upload (made in step 1), if not Change it by using the below commands, for listing the files in a directory
ls
for changing the directorycd
Now it's time to initialize the contents in the repository, use
git init
Primarily there are main and master branches, to check the branch you are in use
git branch
to change the branch dogit branch <branch name>
(Note: If you are a beginner use this once when you start contributing to a project)We've to add the contents to a platform called stage and from there we will be pushing our code to GitHub, for that use git add If you want to push all the contents in your code use
git add .
If you want to push selected filesuse git add <file name>
Note: Here replace the file with the file name as per your requirements.Now we are creating a sanpshot of what changes we made along the timeline, we will be doing this using
git commit -m "Your message"
Now to establish a connection between your local git repository and remote repository use
git remote add origin <ssh/https link>
Finally, you have to push your repository created locally to GitHub using
git push --set-upstream origin master
Or
Just type
git push
After this, you get the above command just copy-paste itBoom, you have successfully pushed your repository to GitHub.