Chapter 10: Deploy Lightning Web Component from Visual Studio to Github

By Gyaneshwar Malba

In this Chapter we will learn how to push LWC Files from Visual Studio to Github

Let’s Get Started !

1.Git : It is a distributed version control system. This tool is used to push files from local PC to Github or pull files from Github to local PC. Git can be run on terminal in windows or any other terminals (Eg: Gitbash)

2. GitRepository : It is place to store code or files and share it with others

Way 1 : We can create git repository (folder) in our local PC and can deploy it to the Github to share it

Step 1 : Install Git in your system (Link : https://git-scm.com/downloads)

Note : Open command prompt and type “git –version” to verify if git is installed

A close up of a logo Description automatically generated

Step 2 : Create account on Github (Link : https://github.com/)

A screenshot of a computer Description automatically generated

Step 3 : Create New Repository (Ex : DemoRepository) on Github and copy the URL (Note : Verify if git is installed in VS code) (Keep it public)

A screenshot of a computer Description automatically generated

Copy the Remote Repository URL from Github

A screenshot of a social media post Description automatically generated

Step 4 : Verify if git is enabled in VS Code in settings

Click on the Gear icon in the bottom left in the VS code which opens the settings, type “git” and check if it is enabled in VS Code

A screenshot of a cell phone Description automatically generated

Step 5 : Go to VS Code editor and Open the Folder/project

A screenshot of a computer screen Description automatically generated

Step 6 : Click on Source Control Option in VS Code and Click on Initialize Repository to make the current project selected in VS initialized by Git

A screenshot of a cell phone Description automatically generated

Step 7 : Once you click on “Initialize Repository” one folder is created in your project (.git)

A screenshot of a cell phone Description automatically generated

Step 8 : You can see all the project files now under the Source Control and can see “U” at the end which means these files are untracked (Which means these files are not yet committed)

A screenshot of a computer screen Description automatically generated

Step 9 : Give a Commit message(Ex : My First Commit) and Click on the Right mark to commit the changes (Every time we do commit, we need to type message)

A screenshot of a computer screen Description automatically generated

Note : You get a message (“Would you like to automatically stage all your changes and commit them directly” with options.) I will select “yes” for now for this change

Step 10 : Your Source Control Folder will get empty

A screenshot of a computer screen Description automatically generated

Note: Now Go to your Github repository which you created in earlier step

Step 11 : You can see in the below image that there are no project files in the github repository, as we have just “Committed” not “PUSH to Github”

A screenshot of a social media post Description automatically generated

Step 12 : Select “Terminal”

Run the below commands to upload your project files to Github

Note: origin = Remote repository branch

master = local repository branch

It means that we are pushing from master i.e. local branch to origin i.e. remote branch.

Output

A screenshot of a computer screen Description automatically generated

Step 13 : Verify the uploaded files in the Github Repository

A screenshot of a computer Description automatically generated

Way 2: Steps to create GitRepository local in your PC using Commands

  1. Open the cmd terminal, type “git init” in cmd and you can see inside the folder where you want to create your local repository

NOTE : One folder “.git” will be created

  1. Create one text file (First) in the repository folder

NOTE : git is still not tracking the text file

  1. Type “git status” and it shows that there is one file which is untracked
  2. To track the files, type “git add filename”

Ex : “git add First”

It is added to the git source code to track the file

  1. Type “git status” command , it says that there is a file which is tracked and which is staged to be committed
  2. Type “git commit” or with comment “git commit -m “File is committed to track the changes by Git”
  3. Type “ git log” to see the changes and the commit history
  4. Let us make changes to the file and see if it shows the changes. Make changes to file (First) and type “git status” to check the changes

Note : git shows that there are changes and not staged to commit

  1. To stage the changes type “git add filename” , the check the status once staged using the command “git status”
  2. Type “git commit -m “Changes should be tracked in git” use “git status” to check the status

Together we can learn faster 

Join LWC study group on Telegram 

Subscribe to Youtube channel and blog to get latest updates

Follow Gyaneshwar Malba on Twitter

Did you enjoy this article?
Signup today and receive free updates straight in your inbox.
I agree to have my personal information transfered to MailChimp ( more information )
50% LikesVS
50% Dislikes