OK we'll come back.
So I want to briefly give you a little bit of an overview of what we're going to be doing with get and
get help.
I mentioned this a little bit in the last video.
Basically our progression here is that we've already talked about conceptually what get and get have
are we we we talked a little bit about why you would use it how it's useful what we'll do next is see
the very very basics.
So for the first two videos I guess the second and third video if you include the first intro we won't
be dealing with get help at all.
So we're not sharing code with anyone.
We're not getting anyone else's code.
We're just using it locally as a way to you know save our changes and revert back to old versions of
code.
So these two videos will cover some really important commands.
And then we're going to talk about get home and we're going to talk about taking code down from get
home.
So I'll give you some code an app that you can then clone onto your machine and run on your machine
.
And then also you'll be able to push that code or push your own code up to get her to share with other
people so that they can clone it down.
So that will be what we finish up with.
And there also be an exercise in there as well.
For now we're starting right here.
So three main commands going to talk about as I mentioned in the last video if you're using Cloud 9
which everyone should be if you're not you're a little bit on your own as far as installing good.
It's not terribly complicated but sometimes you run into problems if you're missing certain dependencies
.
If you've already installed it before it's a little bit it's not fun sometimes.
So luckily using Cloud 9 we already have get installed as we saw here.
Don't worry about the version as long as you see something here that isn't get not found or command
not found.
So the first thing we have to talk about is get in it.
So right now I'm instead of a directory called Get that I created and I'm going to make another directory
and just call it an intro.
Let's call it get intro CD into that.
And inside of this I'm going to create a really simple application.
It's I wouldn't even call an application but I'm going to add some files and let's pretend that it's
a gigantic application that I know I want to track I want to use it to track my changes and revert back
if I make a mistake.
I want to be able to step by step see the code that I wrote every day or every time a committed changes
to do that.
I first have to tell get that this good intro even exists and I want it to care about it.
So it isn't just always watching every file on our computer.
That would be pretty crazy.
Instead we have to manually tell it initialized get in this directory.
Basically get ready get I'm going to use you in this folder and it only works in that folder and any
folders that are inside of that folder.
So it won't work if I initialize get.
Let me make sure this refreshes here.
There we go.
If I initialize it instead of get intro right here and I'm tracking all the code instead of get intro
that works fine but it won't track any changes they make over here or over here.
If I wanted to watch all of this together in one repository if I want to get to know about everything
here then I would initialize get in this webdav boot camp folder.
Usually you don't want to do that though.
Usually you have one repository for one project.
So one Ribault that's where a lot of people say repo rather than repository per project.
So this is our demo project it's called Get intro and the first thing I'll do is just make a file.
So I'll just call this app.
J.S. Yes let's open that file up so nothing involving get yet.
And let's add something in here.
So just a single line count about log.
This is my complex app just so we have something to work with.
So pretend again this is a big app.
OK.
So the first command again is get in it and that's all we have to run.
So we just want to make sure we're in the right directory get intro and then rerun get in it forget
initialize and then you can see I get a little printout says initialized empty get repository in and
then the name of the directory that I'm in get intro.
Also notice that it added this dot get.
We haven't really talked about this much but things begin with a dot dot get the I type ls.
It looks like there's only x J s here.
But if I talk type LS dash a.
You can see there's actually a folder called does it.
And those are hidden folders.
In this case just one get.
So when we run get in it what it actually does is it makes a directory it's hidden called Don't get
wherever I run that get in that command and it's going to track all of our changes.
That's basically the magic that's where all of it exists.
So if if I'm working on a huge project with 20 different files and I have you know committed my code
a bunch of times I've been working on it for years maybe and I delete that don't get folder I potentially
have lost everything if I didn't have it backed up if I wasn't using get have I would lose all of the
changes all my history.
So it's important that you don't screw with that.
But usually you won't even see it unless you're looking for it in the event that you do want to get
rid of it.
If you messed up and you accidentally initialized get repository on your whole computer you did it on
the home directory or you did it you know up here on webdav boot camp or whatever your equivalent name
is and you don't want to track every single file on your computer at once.
Then you want to remove this and you would remove it just like any other directory Ahram dash Aref.
OK.
So that was a side note.
The next command I'm going to show you actually have an added here going to add it now get status.
So this is an important one.
It's not really an action doesn't tell get to do anything.
It basically asks for a status and it's a really common thing to type before you do anything else.
So you usually check in with get.
You say what's your status.
And then it will tell you something and then you do something based off of that.
So right now if I type get status all that it tells me there's going to be a lot of language here that
it's pretty confusing at first.
Says on Branch master you don't need to worry about what that is all that you should know here.
See in parentheses I see M. That tells me that I'm on the master branch what are branches and I can
talk about just yet initial commit.
That means that I haven't really made a new commit.
I haven't done anything yet.
And untracked files app J.S. nothing added to commit but untracked files present.
So the first thing that I want to do is show you what happens when I add a new file.
So let's add a file called Cats genius.
And if I type get status now it now tells me there's 2 untracked files actually and cats genius.
And the reason that it says they're untracked this is this is actually really important to the way that
it works.
Is that just by initializing a repository in a folder.
It doesn't automatically know about or doesn't automatically track every file and every change they
make.
The way that it works it's kind of a two step workflow.
So I can have a bunch of files but maybe I only want get to know about two or three of them.
So a common example is if you're working on a project that has some sensitive application codes or some
secret codes that you need that you don't want to share and get hurt but you don't want to publish what
you can do is tell get to watch the other files but ignore your secrets file or ignore your environment
file whatever it's called.
There might be some sensitive data that you don't want get to know about.
So by just initializing it get tells us.
I know there are these files but I'm not tracking them.
So if we want get to track these files what we need to do is use the next command which is get ADD.
So I mentioned it's a two step workflow.
We add the files we target here the files.
I want you to track and then we commit and commit is basically making a check point in time with the
changes that you've added.
It will make more sense once we get a little more practice.
So let's start by using it.
And so if I type get add I don't want to just hit enter yet.
What I can do is either add one file at a time like this get add app.
Yes.
And now if I type good status you'll see something changes says untracked file.
Still catch stuff.
Yes but now it says change is to be committed.
New File app.
Yes.
So what this means is that when I run get commit which I'll do in just a bit.
This is what is going to be saved.
The fact that we made a new file called apage.
Yes.
So let's try committing this when what that will look like is in the future.
I could come back to this point in time where all I did was create app yes.
I haven't added cad's so that change isn't going to be committed.
So if I reverted back to this in the future when I had made a bunch of changes all I would see is actually
yes with one line in it but catchiest wouldn't exist because it isn't tracking it it's not going to
commit it right now.
OK.
So I'm going to type get commit dash em and dash em.
I believe it's short for Dash message.
It allows you to just type in a commit message right here and this is really important.
Every commit needs to have a message that describes what what the committee is or what the thing is
that you're saving.
The checkpoint is.
So if this was a novel you might have something like finished chapter 5.
If this was an application you might have ADD user model or add authentication.
In this case to add let's to add app file something like that and it's conventional to have your commit
messages be in present tense so not added app file but add app file or change file remove x y whatever
it is.
OK so get commit dash em.
You don't have to do it with Dash em if you just hit get commit.
It will open up a text editor and then you can type something into the editor and hit enter or save
.
But let's just do it like this.
Notice it says here after we committed one file changed and now our type get status.
You'll see that the changes to be committed here new files object at dodgiest has gone away because
we committed it and it doesn't have anything else to keep track of.
There's no changes that we've made.
The only thing that it's complaining about is not really complaining but it's saying that there is a
file cache S that is not being tracked.
So let's now add that get add cats.
Yes.
Let's commit again or let's do get status.
You can see changes to be committed.
The fact that we made a new file Catts genius.
So will do get commit to Ascham add Catts file and accidently hit enter.
Make sure I have that quote there.
Now if we take a look at gets datus we get a new message.
It says nothing to commit.
Working directory clean.
What that means and it says working directory clean basically means the repository it get knows about
everything that we want to know about.
There is no changes to be made there's nothing to be committed.
There aren't any untracked files.
It is one with our code at this point.
All right so now let's say that I have my application I'm going to open up the cats file as well.
And let's suppose that this is a obviously a larger application and I make some changes.
So in here.
Cancel that log now save.
Now if I type good status I changed the cat's G-S file.
You'll see that it tells me changes not staged for commit modified catch SJS.
So gets telling me the catchiest file was modified before it was saying that cats genius was created
it was a new file and if we removed cats us get would tell us.
Here's a change that I know about cats J us was removed so modified catchiest lets add in a commit again
.
And if I try and commit right now I can write any message in here.
It won't actually do what we want because notice that it's saying changes not Stage 4 commit and no
change is added to commit.
So if I commit right now I haven't actually told to.
I want to commit any changes.
Remember that it's a two step process so we don't just add a file one time.
What we do is actually every time we commit we tell get which files to add to that commit.
So that means that rather than having one blanket commit That's more like a traditional save.
If I just hit Save it would save everything.
Rather I can tell it.
OK this is an express app with 20 files.
Let's take the two model files and add them and commit that and we'll say we added in 2 new model files
.
Then let's take our 2 route files and add those together and commit them together and we could say we
refactor middleware wherever we did.
We can group files together and add them in pieces and commit them together but not have to commit everything
all at once.
So in this case I'm going to do is add that file again get add cats that genius that are going to do
get commit and this time all that I did was add meow to cats.
Now I type get status nothing to commit.
Working directory clean.
OK.
So let's do one more thing let's add one file and so will do.
Touch Dogstar.
Yes and if I type get status again.
When C is telling me that it's not even tracking dogs J s so I can add that it had dogs japes.
I'm not going to commit yet.
But now if you take a look is telling us all right when you do commit I'm going to commit.
The fact that you made a new file called Dogs J Yes.
Now let's go and change our apt J s a little bit and add a other council dot log
just like that save.
I do have to save in order for any of this to work and I get status.
Now it tells me changes not state for commit.
The fact that you modified.
Actually yes let's also modify Katz J us counsil Dalt log.
That's do per
save.
Type get status again.
And now you can see tells me that I modified the address and then modified cats.
Yes but I'm not staging them for committing they're not ready to be committed.
The only thing that will be committed is the fact that I made a new file called called Dogstar.
Yes so what I'm going to do is commit once now and then this commit I'm going to say add Doug's file
type get status tells me no changes added to commit to changes are not stage for commit so let's add
them together and what I could do is say Get add objects and then catch separately.
Or I can do this.
Get add dot and that will add all the changes.
Not stage for commit.
So in this case both files.
Now if I get status again now it tells me change is to be committed after this and cast J.S. so I'll
commit them together.
And usually you would put some code here that talks about the feature that you did or what you added
or updated or whatever you did.
In this case it's kind of trivial but let's just say update files which is really not a great commit
message if you're actually working on a substantial project.
OK and then let's take that as one more time and it tells me nothing to commit.
Working directory clean.
OK so so far all that I've showed you how to do is basically adding checkpoints in time that we can
go back to but I haven't shown you how to go back to that.
And that's coming up next.
But let's do a quick recap.
So the very first thing we have to do if we want to get to we have to run get a net that will initialize
get a new repository in a given directory.
And you do want to be careful about that.
You don't want to be making a repository.
Usually don't want you making a repository in the very top level directory of your computer.
Usually it's one project per repo.
Technically you can use it however you want but that would be pretty crazy if you if you are watching
your entire machine with one repository and then the next command resaw was get status and that doesn't
really do anything.
Doesn't tell get to do anything it just asks for an update.
Basically we're asking get what's the current status.
Has anything been added.
It's ready to be committed.
Are there any changes that sort of thing.
And then these two are really important.
These are the bread and butter of get.
You'll type them all the time.
So we add the changes.
We basically select what we want to add to this check point in time and then we commit the changes to
add that checkpoint and we give it a message so that in the next video when I show you how to view the
commits we'll actually see those messages and future you will be very thankful that you hopefully wrote
nice messages that are descriptive so that you know what each checkpoint what each commit does.
OK so in the next video we're going to talk about get log in get check out