Push your first repository to GitHub in just 15 steps

  1. Create a folder

  2. Open the VS code and open the terminal

  3. locate and open the file created in Step 1

  4. Create a file and add contents to it.

  5. open Git Hub

  6. 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.

  7. open terminal inside VS code

  8. 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 directory cd

  9. Now it's time to initialize the contents in the repository, use git init

  10. Primarily there are main and master branches, to check the branch you are in use git branch to change the branch do git branch <branch name>(Note: If you are a beginner use this once when you start contributing to a project)

  11. 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 files

    use git add <file name> Note: Here replace the file with the file name as per your requirements.

  12. 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"

  13. Now to establish a connection between your local git repository and remote repository use git remote add origin <ssh/https link>

  14. 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 it

  15. Boom, you have successfully pushed your repository to GitHub.