How to use(initialize repository) in Github using git and Visual Studio (VS code)
- Create a Github Account.
- Now you must also download git from https://git-scm.com/download/win.
Or simply search git in your brower the first link will probably be one for git.You can click into this image that will redirect to the website.
- Now click on Click here to download for latest version.
- After git has been downloaded you must set up git, just tick every field and do next until git is setup.
- Now once git is installed, open git bash by searching into your windows search bar and you must enter some
commands for git to run along with vs code.
- Now you must add your username and email into git bash.
- To enter username the command is:
git config --global user.name "yourname"
You must write your name in place of yourname in command. Then press enter.
- Continue in same page. Now you must enter your email. To enter email the command is:
git config --global user.email "nickeshadhikari@gmail.com"
You must enter your email instead of my email. Then press enter.
- Now you can check wheather your username and email is saved or not by running a command in the same page. The command:
git config --list
Then press enter.
- Your email and name will be shown as above if commands entered correctly.
Step 1 to Step 9 is only required for FIRST TIME and once these steps are done they shouldn't be done for next time for initializing other Reposiories. After first Initialization follow from step 11.
- Now after creating an Account in github and setting up git, you will have such preview in your github account.
Then click in plus + icon near the search bar. Now you will get these options, you must then choose New repository among those options.
- Now you have to name your Repository. Name it according to title of your website.
- After giving name to your repository let other option as it is and click in create repository.
- Now you will be provided a link of your repository by github itself. Copy the link.
- You must have a separate folder that you want to publish in github.
- Also be careful when you name your HTML file. You must name the file that opens first as index.html else your HTML code won't work for your website.
- Now go to VS code I assume you know basics of programming and know how to code using HTML.
- Your Visual Studio Code should have such preview.
- Now click in third icon below search in the left of vs code (that is git).
- Now an initialize Repository option will appear click initialize repository.
- Now click on three dots that appears at right top of message box and go to remote and click add remote.
- Now add link of your repository in above search bar setion of vs code. Just paste the previous that you copied from github as your repository link.
- Now add the name that you want to give to your remote.
- After giving remote name, Now click + icon that is besides changes as below.
- Now add message in message box above commit option. you can add anything in short that defines your commit. Like "first commit" for your first commit.
- Now click into Commit.
- Now click Publish Branch.
- Now you can view your reposiory in your github profile as below.
- Now click into your repository that you want to publish live as website.
- Now go to settings of your repository and on left side of setting you can find pages. Go to pages.
- Now on branch opion choose main, if you don't have main choose master and on second option choose root and click save.
- Now your website has been published and is live to be view by any one. It will take few minutes (less than 5 minutes) for it to publish.
- Such link will appear when website is ready. Link will appear in pages.
CONGRATULATIONS!!
Now you can share the link of your website with any one.
©2023 by Nikesh Adhikari. All Rights Reserved.