Instructor: In this video, we're going to put
all our code onto GitHub, or as we usually say,
we're pushing it to a remote branch.
To get started, head over to github.com,
and as soon as you're logged in,
just click here on this plus button
and create a new repository.
Now once more, if the page looks a bit different
at the point you're watching this video,
then just search somewhere on the page for new repository.
Okay, so first off, you need to
give the repository a name.
So I'm calling it natours here,
which for me is not possible
because I already have a natours repository,
so I'm just calling it natours rec for recording,
but you can just go ahead and call it natours.
Then we can also add a description,
which I'm not going to do,
and then we can set it to public or private.
I think that right now, even the free accounts
can have private repositories.
Private repos, as the name says,
only you can see and you can also invite other people.
With public repos, they are of course
visible to everyone, and so they are
perfect for open source code.
In this case, I'm just leaving it private,
then leave all these defaults,
and here it's very important that we do not
initialize this new repo with a readme,
because that would then create conflict a bit later on.
We really want this repo to be brand-new
and completely empty here on GitHub.
Doing this here is similar to
what we did before locally with git init.
The only difference is that this time
it really is on GitHub,
so it's a remote repository now.
Great.
Now the goal here is, to basically push
all our local code into this remote repository, okay.
In order to be able to do that,
we need to let our local repository know
about this remote repo that we just created here.
Okay, so basically we have to kind of connect them.
That's exactly what is set here.
What we want to do is to push an existing repository
from the command line, and so let's go ahead
and copy this code here
to our command line here, okay.
What is this going to do?
Well, it will add a remote branch.
Remote means that it's a hosted branch, basically.
And this remote branch, or you can also call it,
this remote repository, is going to be called origin,
and it is located in this url here,
so at this location.
So hit enter and that's it.
Now these two repositories are basically connected.
At this point, we are ready to do git push,
which is the action to basically copy our local code
onto our remote branch in our remote repository.
Then the name of the remote branch
which is origin, and then the name of
the local branch, which is master, all right.
So git push origin master.
Hit return, and then that should
of course take some time.
Now first up, it also asks us for our username,
which is just the email address,
and probably you don't need to do this anymore
because you already specified it,
but I didn't before in the video, remember that,
so let's do that now.
By the way, because I'm using a different account
on my computer to record this courses,
and so I don't really use git here,
and so that's the reason why I needed to do it.
Now anyway, it now asks me for my password,
and so write your password here,
hit return as well, and so then
it should start sending the data to your remote branch.
It's doing that work now.
You can see all the statistics,
how many files there are, your upload speed,
and how much there is already done.
All right, so I will come back once this is finished.
Okay, and that's it.
So let's now check that out here on GitHub.
Let's reload, and indeed, here we go.
And indeed, here we have all the files
that we just added to our commit before, all right.
You see that all of these here
say initial commit, and then this file,
app.js, where we actually did some modifications,
it then says added a comment,
which was the commit message
that we used for that specific commit
where we only committed this one file.
Remember that?
So it actually was six minutes later.
Great.
Let's just take a look at that.
How it looks like here in GitHub.
Yeah, that's all our code.
Nicely hosted now basically in this place, so in GitHub.
You also see that our ignored files are not here.
The node module and also the configuration file,
so exactly the files that we really do not want
in a repository, well, they are now
not here just as expected.
Now by the way, the opposite operation of push
that we just did, is the pull operation.
So imagine you're working on two different computers
and want to start to work on one computer
and then continue on the other one.
To do that, you could push the code on one computer
onto GitHub, and then on the other one, simply pull it.
That would be very simple.
The command would be almost the same,
but instead git pull origin and then master,
so the branch that you're currently working in.
I'm not going to do that now,
but instead I will create a readme file.
That's a very standard file that
every single repository should have.
Let's do that here.
The standard really is, so not a folder
but a file, and so again, the standard is
to call it readme.md which stands for markdown.
This file here is written in markdown.
Let's use this hash symbol here
to add the main title.
Let's call this natours application.
Then just a paragraph below that
built using modern technologies.
That's not really correct, technologies.
Node js, express, mongoDB, mongoose and friends let's say.
All right, so let's save this now.
And if we now say get status, you should see this
as a new file, and indeed, here it is.
Now actually, after closing and opening again,
the VS code app, this part here of the application
actually started to work.
Now you see here, that the readme.md file
shows up under the changes.
It shows up here as U, which means untracked.
Okay, and also as I mentioned before,
you cn actually see that here in the file tree.
It's green now, okay,
and if you change, let's say another file,
for example, chaining here to application.
Get it a safe, then you see here this M,
which stands for modified.
It also shows up here.
Here this bar then becomes blue because
now it's modified, so this is a modification
and not an insertion.
Before it was green because I inserted code
and now it's blue because I modified.
Here I can also very easily go back.
I want to discard the changes,
and so you see it goes back
to what it was before, okay.
Anyway, let's now add this file to the staging area.
Git add and then you can use tab
to auto-complete as always.
Then let's now commit it so git commit the message
added a readme like this.
And now, let's also push it to our remote branch,
just so we can take a look at time in GitHub.
That's git push origin master.
Let's take a look at that here.
And now, here you see that readme that we just created.
You'll see also that the commit message
for this one is added a readme one minute ago.
All right, great.
That's it, that's the absolute fundamentals
that I wanted to show you in this lecture
and the last one about git and also GitHub.
All right, now another thing here about GitHub
is that many times when starting on your project,
we actually do it the other way around.
I first create the repo on GitHub
and already with a readme file,
and then after that, I pull that repo
onto my local computer, all right.
That will then automatically connect
the local repository with the remote one.
That just makes the set-up a little bit easier.
Many times, I do it just like this.
But of course, the way I explained it
in this video is also perfectly fine.
Anyway, I hope that this has been useful for you.
In the next video, we will start
preparing the app for deployment
because there's still some small changes that
we need to do, so some modifications,
in order to be really ready to deploy the application.