In this video you're going to initialize get in the web server folder.
Once our project is under version control we'll be able to track changes to all of our application files.
Now as I mentioned in the last video when we want to use get we have to explicitly initialize it in
the project where we're trying to use it for us.
That means we need to run a command from the web server folder.
Now it's important that we run this command from the web server folder and not from a nested directory
like the public folder or from a parent directory like node Course the Command we run needs to be from
the root project folder which is web server.
So right here in the web server directory we are going to use the get in it command.
Let's run the command and initialize get in our project when we do that quite a few different things
are going to happen.
Let's go ahead and start with the output we're getting in the terminal down below.
Right here we got the following message initialized.
Empty.
Get repository in followed by a path to our project folder to the web server directory where we ran
the command from from there get has created a new folder.
Dot get this is where get stores everything that makes up your get project.
So as we add new files and create new commits those are going to end up getting stored in data structures
inside of Dot.
Get this directory is not something we're going to manage ourselves we're not going to go inside of
there and change or add things.
Instead it is managed by get and it gets altered when we run get commands which we'll do in just a few
moments.
Now you'll notice they're using the term repository outside of the context of get a repository is defined
as a place where things are stored.
So a get repository is nothing more than a place where things related to get are stored.
We're going to see the word repository come up quite a bit in this case.
We have a local repository.
It's in a directory.
Dot get on our machines as we start to integrate with get hub and Heroku.
We'll have remote repositories where our code is backed up.
For example Heroku needs the code to deploy to the server and get hub needs the code so it can actually
use it as part of its little software project management platform.
Now that we have get initialized let's talk about a couple of the other things we're seeing here in
the tree view on the left hand side bar everything in the web server folder just showed up in green
so Visual Studio code by default has it get support and when we initialize a project it shows files
in green that have not yet been committed.
So these are brand new files which would show up under that on tracked files category that we had saw
in the previous video.
You'll also notice that while a new directory was created it's not showing up inside of the web server
folder where it actually lives.
That's because Visual Studio code hides that directory by default.
It's not something we're manually going to change or manage.
Now if you wanted to see what's inside of there you could if we go up to code Preferences Settings we
can change the setting to actually see that directory.
Let's take a quick moment to get that done under commonly used.
If we scroll down about a dozen or so settings we're gonna see a small list of excluded files and folders
one of them being dot get.
That's why it's being ignored in the tree view over here.
Let's go ahead and change this.
Instead of dot get with one T.
I'll just use dot get with two T's.
We're going to click OK and we'll revert that change in just a moment and when we do we can see that
a GET DIRECTORY does you show up if we crack that open.
We can see there are all sorts of things inside of here.
This is what makes up the get repository.
And this is the stuff that we're never going to touch.
So let's go ahead and collapse that directory.
And we're also going to alter the pattern once again to have just one T.
We'll click OK and that'll make sure that the get folder is indeed hidden.
So that is what get in it does the only thing it does is it creates that new directory dot get and add
initialize is the project.
From here we can start the process of using the ad command and the commit command to actually track
things with get from here we can go ahead and run another command from the terminal.
This is the get status command get status prints the current status of our setup and this is going to
show us output similar to what we saw in the visualization in the last video.
If I run it one of the main categories here is entourage files and under there we can see all of the
things that make up our project we haven't created a committee.
So nothing is being tracked and that's why everything shows up under here.
We have node modules we have our two Jason files we have the public directory list source directory
and the templates directory.
So from here we could use get add to add things to the staging area and get commit to actually commit
them before we do though.
There is a single folder in our project we don't want and get to track and that is the node modules
directory when you're using get and you're using NPM you don't want to get to track the node modules
folder as this is a generated directory.
We can always recreate it by running npm install npm install is going to use the contents of package
Jason and package lock dot Jason to bring this directory back to its exact state.
So get doesn't need to know what's inside of node modules what's inside of there is a ton of other files
and folders that are already under version control by the project owners.
Now get gives us a very easy way to ignore things from our setup.
We do that by creating a new file in the repository root for us.
That means we create a new file in the web server directory and we're gonna call this dot get ignore
and the name is very important.
If it's not exactly spelled right gets not going to be able to find the file.
Now in here we can simply list out the things we don't want and get to track.
And for us that's going to be node underscore modules forward slash.
Now when we do this get is not going to track that directory even if we tried to use get add.
We'll see that it won't show up under contract files and we can go ahead and rerun and get status to
prove that I'm going to run and get status once again.
Right here we can see that node modules is nowhere in sight which is a good thing.
And then we have dot get ignore it which is showing up because that's a new file we've added.
So at this point in time everything in Entourage files are things we actually do want to track.
These are the things that make up our application and we want to keep track of all of these files over
time.
That means that we're ready to create our first commit.
You'll notice that up above node modules is now grayed out.
This is Visual Studio code letting us know that well this thing exists.
It has been ignored by version control.
We can still open it and look at what's inside.
Everything's just shown in a lighter gray to signify that it's ignored down below we can now use get
added to add things to that staging area right here that is get add.
Now when we use get add we have to list out the things that we want to add in this case we can list
out things we are seeing here in Entourage files I could list out individual files or entire directories
for example get add followed by source forward slash when I do that it's going to add all of the files
in the source directory to the staging area meaning they're ready to be committed I can run get status
to see that right here get status under contract files you'll notice that the source directory is no
longer listed.
That's because we've added it to the staging area so it's showing up up above.
Under changes to be committed.
Right here we have all three files that exist in that source folder.
Now we could choose to make a comment with just these files in it but I do want to track all of the
files that we have listed down below as well get add it gives us a shortcut to add everything that is
get add dot.
This is going to add everything to the staging area which in this case means everything listed right
here.
So I'll use get ad done then I'll run and get status once again and we can see that now we have a whole
bunch of files listed under changes to be committed.
We no longer have that on track to file section because there are no entourage files left now that our
staging area is set up.
We can actually create the commit and we do that using get commit.
That is SEO and I.T. and we have to provide a message with each commit describing what exactly changed
right here.
We do that by providing the M flag followed by our message inside of quotes and for the first commit
something like initial commit or in it commit is typically used as we create other commits will describe
exactly what we're doing.
Like adding new feature to allow people to communicate privately or adding support for image uploading
a nice concise description of what exactly the changes are adding to the project.
In this case though in it commit gets the job done for that first commit.
I had enter and what happens.
A new commit has been created now right here when we run that commit command we get a bunch of output.
I can see right away that we have 16 files being changed and all 16 are listed down below and right
here.
All of them are being created for the first time they're being added to get I see create next to all
16.
So at this point we have one commit inside of our get repository and you'll notice over here that all
of the files are back to their default color because now they are not new.
Entourage files as we make changes to our application though the colors will change once again.
For example in app dot J S I had this console dot log call which we had previously used to make sure
the file was actually running.
I'm gonna go ahead and remove that Save the file and over in the left hand sidebar I can now see that
old directories up to and including app dot J S they're showing up in orange.
This means that we have changes to a file that get is already tracking.
So I see that for web server public J S and for the modified file itself.
So at this point we now have a single change made to the project and we could add that to the staging
area and create a another commit.
Now let's go ahead and run get status get status is something we're gonna run a lot throughout this
course.
So we can make sure that our changes are actually doing what we're expecting them to do.
And right here I can see we have just a single category changes not staged for commit.
This is the onstage changes category from the previous video where we had our visualization.
Right here we have one modified file it is app not J.S. in the public J.S. directory which is the exact
file we had modified up above in the text editor.
Now we can actually add this to the staging area and make the commit so to add it to the staging area
we'll use get add I could either list out this individual file or just use get add dot to add everything
which in this case is just our one file.
Either way works from here.
I'm gonna run get status again before committing just to make sure everything looks right under changes
to be committed.
We have a single modification to a single file so I'm ready to make that commit right here.
That's get commit with the M flag to provide our message and I can use a message like remove unnecessary
console dialogue.
Call.
Perfect.
Now that we have the message in place I can hit enter to actually create the comment and write down
below.
We get our output.
I can see that we had one file changed and we had two deletions.
We deleted line 1 and 2 line 1 had the console dialog in line 2 was an empty line between that and what
we now have as line 1 up above.
So now we have a local get repository with two comments one which added everything into the repository
and another which tracked a change to one of our already tracked files.
Now it's time for a quick challenge where you're going to put the notes app under version control.
I have challenged comments sitting right here as I just mentioned.
Goal is to put the notes app under version control.
Step one is to initialize a new repository or repo for short in that project directory in the notes
app folder.
Once you have that in place you do want to tell get to ignore the node modules directory.
Since that project also uses modules from NPM and we don't want to track that folder and last up you
want to commit all files to the repository creating an initial commit and to do that you'll use a combination
of get add and get status and obviously get commit.
So take some time to knock that out put the notes app under version control creating a single commit
with all of the project files except for what's under node modules then come back and click play.
How would you do.
Let's go ahead and work through this process together.
First up I'm going to close down Epcot and J.S. and I'll temporarily switch from web server over to
notes app and I'll do the same thing in the terminal down below C D dot dot to get out of the web server
folder then forward slash notes app to go into that directory.
From here I'll use clear to clear the terminal output.
Now the first thing we want to do is initialize a new repository for this project and we do that by
running get in it as we did before.
This is going to set up a new repository in the notes after rectory and now we're ready to start the
process of actually setting things up the way we want them.
The first thing we're gonna do is make sure that node modules never finds its way into the repository
by setting up the getting your file right here.
Don't get ignore and then we will set it up with just one entry node underscore modules forward slash.
Now we can see that's been great out which means that that directory and the files inside of it won't
get tracked.
From here we can move on to the last step which is to create our initial comment.
I'm going to start by running get status just to make sure everything looks correct down below.
The only category we have is on tracked files and we have our files under there.
We got all six of them.
From here we can use get ad with DOT to add all of those over to the staging area and after I do that
I will run and get status once again to make sure that things look good.
Right here we have all of the things that are gonna be committed the next time we create a comet and
this is what we want.
We have our files here without node modules so we can go ahead and wrap up Step Three by running get
Comet.
We'll provide a message and we can use in it.
Comet which is typically the message used for the first comet so right here we're going to create that
comet and we can see that for all six files we have create mode being used.
We have six files changed and we have five hundred and eighty seven lines being inserted now that we
have this in place the notes app is under version control.
If we were to make changes to the application in the future we would be able to track those changes
as well.
Now I'm going to run C.D. dot dot forward slash web server to switch back to that directory since the
challenge is over and I'll use clear to clear the terminal output and I'm going to switch from the notes
app folder back over to the web server project.
That's where we're going to stop before this video now that we have the basics of get set up.
It's time to focus on getting the code on github and Heroku.
That's what we're going to start to do in the next video.
I'll see you then.