How to connect VSCode Salesforce Project to GitHub ? | Getting Started with Version Control System

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
even this is a letter from a video we are going to learn it how we can connect our on Salesforce project to get up right so github is nothing but a better service provided I can say which which allows you to share your code among multiple contributors and it is based on the gate platform so we are going to see how we can actually upload our wholesale source project among all the configurations and all the classes everything to get up and we are going to create a new github repository here and we are going to push our code to get her by adding a commit right so what I did I just created a new scratch rock and I actually installed my epics actually actually I installed my I say typical of framework in this scratch work so that I have some of the code because by default a scratch okay than empty orc so I just added some of the epics classes some of the layouts and everything that is a part of our city we call our framework - my orc right and I connected a new I mean I I actually created a new vs code project and I connected it with my scratch shop and I take a pull due to which I have I have some of the epics classes in my vs code now and I also have some of the custom metadata layouts validation rules objects and all that stuff right so I'm going to just initialize a new github get repository in here and I'm going to push everything to my new github repository that I am going to create very soon so let's begin so the first thing that we need to do is to create is to initialize the gate right so to initialize the gate you just need to move on to the third icon here which says source control and here you will see you have a button which says initialize the purgatory so you just need to click on this button and it will automatically initialize the repository for you so if I just show you the output of git here if we can see yeah there are a lot of commands but yeah I can tell you I can tell you in other words if you want to nice place a git repository using command you can just use git init and it will automatically in a slice repository for you so the command to initialize it up is it risk it in it in case you don't want to do it using using the UI but you can just click on that button it will automatically nice right so what are you showing me right now is that these all the fire is that are part of my project they are not been added to get right now so what I need to do I need to just add them to my gate so that it can be tracked by my version control so just to give you an overview getting the version control system which actually tracks all the files and all the changes that you are doing in each and every file so what it does it tracks all the changes that you are doing okay what anyone is doing who is connected to this particular github repository right so what I did I just in his less gate and I and I told I and I told my version control system that hey now you have to track all all the changes that I am going to do in this particular folder or in this particular project folder right so it is checking everything and it is showing me right now that hey Rahul you haven't done any of the things yet and you have around 44 new files that you should stage or commit so before committing what we need to do we actually need to stage all the changes so staging is something which you can say that hey I am done with my changes and now I can stage all the all the changes and and I mean these are the files on which I have I have stopped working and I am now and now these all files are ready to be committed so staging is something when I when I say that I am stating my changes this means that the files are ready to be committed right and if something is unstaged then this means that I still need to do some changes right so whenever you want to commit or something committing is something like if I talk about commit it's something like I'm I'm fixing or finalizing finalizing the changes that I have done so before committing what is the prerequisite for it whenever you want to add a commit prerequisite the quiz it for commit is to stage the changes so let's say I am doing some of the changes and then I then I realize that okay these files these five files are something that I can commit right so I can I first need to stage all those files and then I need to add a commit you can also understand changes if you want to do like if you see here I have an option to understand all the changes so if you click on this it will automatically understate all the changes so now you can see that I have all the files in the changes under the changes heading so this means that I don't have any kind of any kind of files that are staged I can also manually state some of the files let's say I want to I just want to stage these two files so I can click on the plus icon over here and I can manually stage some of the files that are ready to be commented right so like you can see here that whenever I am adding a plus icon I'm I'm clicking on the plus icon manually the files are being staged and all the other files are unstitched so we'll see that how we can how we can actually you know push our state's changes after committing to our github repository so right now I am going to stage all the changes so this is a this is I think most preferred thing whenever you are creating a new vs code project or you are starting with a new skillfull project or even if you do if you have an old project like here I'm taking a scenario where I have an old project but now is the time that I am taking it took it for the first time right so whenever your first time taking something to get or taking or moving I should say moving a project to get you need to stage or stage everything so whenever you are doing this just stage everything and add an initial commit so that after this initial commit your each and every change will be tracked automatically right so I am going to stage everything I have staged everything here and I am going to add a commit so just to add a commit what you need to do you need to specify a commit message so you can specify the commit message here and you can add so let's say my commit message for this commit is initial commit right and I'm going to click this icon which says commit so this is a right tick over here if you click on this stick your first commit will be done so I'm just going to click on this and here you can see that my changes are now zero because I have committed or I have I have done my first comment so how I can see that whatever I have committed I can just go to I can just go to my terminal and I can I can actually execute the command which says get log so whenever you are executing the command which is good log you will see that you have a commit which says initial commit over here right so this is how I mean you can actually you know perform a initial commit and now our next task is to push these changes to our github repository so I have added just one commit into my repository and now I can push these changes to my github so let's say I actually did the I actually you know I want to take my project to to version control system so for this I actually initialize the new github repository and I added a commit and now I am ready to take it let it break it - to github or something like that right but let's say I just realized that I am I need to do one more change and I forgot to do that so I just want to show you that even if you do a very simple chain like let's say I just removed this this opening place over there and I am saving my file right so as I'm saving my file you can see here that it's being tracked by git so now you can see that in the changes folder I have one file which I which I just changed and if I click on this it will automatically show me that here this is the change that you have performed right so this is the older old chain that I have and this is the new change so in the old change I had a semicolon sorry I had the opening brace over here and in my new code I don't have an opening brace over here so this is how the changes are being tracked by git right so for now just to leave everything as it is and I'm going to create a new github repository and push all my code to my github repository so you can see here that as I diverted my changes back the changes the changes part is empty now right so let's create a new github repository and let's push all our code to the github repository right so to create a new github repository you should have an account on github first you can use github bitbucket get lab anything that you like they just need to have an account on github son I'm actually going through the going through the things by considering it up here so whenever you are on the homepage or you are on any page you can either Nisha lies and you github repository from here otherwise if you're on the home page you can initialize and you get a repository by clicking the new button here ok so I am choosing this let's create a new repository and when you click on new repository you will be taken to a new page where it will ask you that what is the name of your repository right ok so here you can see that we need to we need to add a name of our repository so let's say I am adding my repository name as let's say see I see I see the tutorial or something like that right so my repository name is CI CD tutorial and you can also add a description for your repository so description can be anything like this is the repository for CI see the tutorial in SF DC stop or something like that right you can choose your repetetive to be public or private so if your editor is public anyone can access that like if you if you know and if you have gone through my previous tutorial I every time I share the repository with you let's see for platform event toast I have a repository for the atypical or framework I have repeatedly so all these are public repositories because anyone can see them anyone have a look at the code and anyone can add a pull request and clone that rapidity right so if you choose it to be private then it's only visible to you and it's nothing it's visible to no one else right and you can explicitly share it with some persons but if you choose it to be private it's wrongly visible to you so I'm just going to create a public repository for this and you can also initialize your repository for a within me but I won't suggest you to initialize a stripper to three with the readme because we are going to add everything into our repository from our vs code so if you see that our our new sales project already has a readme over there so there's already added me file which sales was provided us when we initialize when we initialize a new sales project using the S code so we don't need to nice leather leave me and we can also add a license and get ignol so these are all good stuff that we don't need to get into right now so you just need to add an obligatory name at the description if you want to choose public or private and then click on create repository so I'm going to create a repository and let's see how it goes so yeah so my new repository is created and by default the repository name is CI - CD - tutorial so I mean these hyphens will automatically are automatically added by github because you don't you should not have any space or something like that in the github repository because we need to use this link right so what we need to do now we need to push all our code into our CI CD tutorial depository that is that is just created right so I have already added a added one commit into my code and I and now I am ready to push it right so before pushing the one thing that I need to do is that I need to tell vs code or I need to tell my local gate that hey you need to push all this code to this particular github repository right so for this what I need to do I just need to click on this button and or I can manually just copy this URL which is my endpoint URL for github repository so I can just click on this or I can manually copy this it's up to you and once you have copied this what you need to do you just need to follow the instructions which is saying push an existing repository from the command line so for this it is already telling you what are the instructions that you need to push otherwise I'm going to tell you how you can push it right so let's go to our terminal and I have already added a commit so my next thing that I need to do is to add a remote or to set any mode right because let's say this is my local repository repository which is in the vs code and I'm going to push this to my github repository right repository which is on the github server so this is this is this is a debilitating it is in my vs code I call it local and this repository which is on github I call it remote right so what I need to do now I need to push my changes I need to push changes from local to remote and to push my changes from local to remote I first need to specify that what is my remote server right so the command to specify your remote server is this which says gift remote add origin and then the URL of my remote repository which is shown here this URL right so I just am just going to copy this and I'm going to paste this command here so you see here that as I pasted this command git remote add origin and this it automatically it automatically actually said set my remote for this local folder which is which is which has the get initialized right I can check out what is my remote URL by executing the command get remote and then - V so it will automatically show me that here your remote URL is with the name origin and the remote URL is this which is automatically set for you right so you can set your remote URL by using the git remote add command so get remote add and then is the name of your remote URL or the elías for that by default I'm everyone prefers it to be origin so the origin is the best thing the best alliance that you can use and then you have to specify the URL of your origin as the command line parameters so once you have executed this command your remote will automatically be set and you can now see that your remote is set now my remote is set but I haven't pushed any changes right so I can check out the status which is right now along with my remote right so if I just to execute git status it will tell me what is the status so right now I am on my branch master so you can check out from the lower side of your vs code that what are the different branches that you have created so right now by default only one branch is there which is branch master and nothing is there to commit because I don't have any specific changes and everything is clean right so I can directly push all my changes to my github repository so to push what you need to do you just need to execute the command which says get pushed so let's execute git push and let's see what happens so it is it is actually saying me that the current branch master has no upstream branch to push the current branch and said that the motors of Shame use this command right so what what is means by upstream branch sure let's say you have a local repository and you have a remote repository right let's say you have you can have different branches I mean a repository is like a tree is like a tree in which you can have multiple branches right because you let's say you have 10 developers working on working on the same repository so they can all they can work in on their own branches right and later on you can mulch bunches so branches branches is nothing but something that that that you can much later on so let's say you have one branch which is coming out of here in your tree let's say from here and then you have another branch which is coming out of this branch or something like that so you can see that this is by branch master and this is my branch a branch a and from my branch a my another branch is coming which is branch B or something like that later on you can actually merge this with masterís and do it like that right so we'll see all this in the future tutorials for now we got to know that we're getting wet get is saying to me is that you have your master branch here in your local repository and you also have some you also need to have some master branch or something like that in your remote repository so that these two branches can be linked to each other right so you need to have something something like master over the remote also so that you can link both the branches and whenever you are actually the cuting a push command it knows that hey you need to push this master to remote master or something like that right so what I need to do I need to execute just this command which says git push - - set - upstream origin master and the same command is also given in shortcut here git push - you origin master so I can also use that or I can use this one right so let's say I use the one that is provided by github which says git push - you origin master and I press enter so let's see if our code is pushed okay so it is asking me for my github username so I am just going to add my username here and it is asking you for my password so I am going to add my password and you can see here it is writing the objects and it is pushing everything to my github repository okay so just give it a second okay so we can see now that our branch master is set up to track the mode branch master from origin and my my master my local Marcel is actually linked to my remote master branch right so let's go to our repository again and I'm going to refresh this page and we'll see if our code is pushed or not okay so now I can see that all of my code is pushed and my readme file is automatically there which is created by Salesforce and I can also see if my epics class is out there or not right so let's click on this for SAP main default folder and that class is full done and let's see if my classes are there or not so you can see here that all the classes are there which I which I created and are in my vs code and they are automatically pushed to the github repository right okay so the one thing to notice in there is that you can see that I have a number of folders here right like I have tabs folder I have static resources folder I have remote site settings folder profile folder I have permission sets folder and a number of folders out there but if you check out your github repository you can ask me one question that here I will if I check out my for SAP main default folder I don't have my permission set folders over there and I also don't have my tab folder my static resources folder so why are these folders not coming into my gate so just to tell you about that our gate by default don't track any empty folders right so if you have any empty folders or if you don't have any data in your folders it will it won't be tracked by gate by default so all these folders that are empty like permission set statical sources tabs they're not by default tracked and all those folders which even have one file like if you see the mode set settings I just have a single file over there so it is being tracked by by your github repository right so it is being tracked by git and it is being pushed so the next question that may come in your mind that do we have to again again and again use this command to push to push our changes so I would say no because this is only for the first time when you don't have a remote setup for your github repository right because now my my local enim and my remote are the sink and I have my remote setup for my github repository so let's say if I do even a single change let's say what what change can I do right now let's say I just add one single change and I and I update my last updated date from seven to let's say 24 24 and April let's say it's 20 20 right and I'm going to save this file and it is automatically pushing to my scratch-off so that my sketchup and my gate are in sync right so if I go to my source control over here and I click on the changes I can see that all my file is my whole file is same but only a single change is there in which I updated the date right so let's say I want to push this change to my github repository where I am where I have updated a date right and I don't I don't want to do anything else I just want to push this single change so I can just change this first of all again the same things I need to add a commit so let's say I adding the commit as updated date in HTTP call out a Singh service plus and I am going to commit this and now to push I don't need to go to my terminal I can directly choose this more actions option over here and I can choose the push command so what it will do it will automatically push to my repositories branch which is connected to my local master branch so now my local but master branch is automatically connected to my name ode master brand that I did for the first time so I can directly push it from here so it is asking for my username and this to add that and it is asking for a password I am going to add this as well you can see here that it is pushing a one change from weather mode to my look well so you can see here it is sinking synchronizing the changes so now all the synchronizes summarizing is done and I can directly refresh my repository on github and I can check if that change is there or not so I have added actually two commits into my repository and let's see if that change has come here too not so now you can see I have two commits over here where I had only one commit and my latest commit is updated date in s2 typical out async service so I can also you know check out anyone commit and check out what all the changes that I did in that particular commit so if I check out this particular commit I just updated one file and in that soil also I just updated the date right whereas if I check out my initial commit I can see all the changes that I did soon then he shall commit I added a lot of files and these files didn't have any previous history because they all are new files and I added a lot of new files and then he shall commit right and even if I go to my github repositories homepage I can check out that all these all these folders or files are related to initial commit however in this particular folder I added a new commit so if I go to this folder I can again see that only in classes folder I added a new commit however all the other folders are having initial commit only and if I again go to the classes folder I can check out that only this but in this particular class I added a new commit and all the other classes are the same right so I can check out and I can even see the time like three minutes ago I added this commit in twenty minutes ago I added another comment or something like that so everything is being tracked although all the changes at the you are you are doing in your scratch job you can pull that or even developer Rob you can pull that in your waistcoat and you can push that into your github repository one by one so this is how I mean we can connect our Salesforce to our github repository the only thing that I want to tell you right now is that I expected here that you have you have installed get in your system right so installed get in your system so this is something that I that I you know pre assumed that you have installed it in your system because you can only execute the gate commands when you have git installed in your system right so in case you haven't installed it in your system you can just go to the go to the git - SCM comm /downloads I will give the link in the description and you can just download it for your own system and you can I mean there are very simple commands to install the gate and in case you want me to create virtually you know add another video or installing it and and start just installing it because I have to I have told you everything related to get here so in case you want another video to install the gate just let me know in the comments down below in the next video we'll see how we can actually actually you know pull a project that is there in the github repository and we can set up a new scratch rock for that existing project that is that is there in the on the github or bitbucket or something like that so till then have a good day bye bye
Info
Channel: SFDC Stop
Views: 41,372
Rating: undefined out of 5
Keywords: SFDX, Scratch Org, VSCode, Salesforce, VCS, Git, GitHub, CI/CD, Commit, Push
Id: AxBu4JARPCM
Channel Id: undefined
Length: 27min 34sec (1654 seconds)
Published: Fri Apr 24 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.