Okay.
So let's talk about how we actually get our code up on GitHub.
How do we take a local git repo on our laptop?
And how do I connect that in some way to a hosted GitHub repo?
How do I connect them?
How do I set up the repo on GitHub?
And then what do I do on my machine to tell it about the GitHub repo?
Well, there's really two different approaches or two options that I'm going to walk through in this
video.
I'm just going to talk about both of them and just explain how they work and then we'll dive into actually
doing them.
So the first option called option one is if you have an existing repo on your machine, if you have
something that you've already been working on, it already has git history, you already have code,
whatever it is, and you want to get that on GitHub.
These would be the steps that you follow.
You create a new repo on GitHub, then you connect your local repo by adding something called a remote.
We'll go into that.
So you add that remote to your local machine and then you push your changes up to GitHub.
So here's some diagrams.
If I have something I've been working on, whether it's just a day of work, an hour of work, an empty
repository that I've created or years of work, whatever it is, if it's on my machine and not on GitHub,
I go on to GitHub and I make a new empty repository.
I'll show that in just a moment to.
So once I make that new empty repository, then what I do is tell my computer.
Specifically tell this git repository about the GitHub repository.
And then I can push my code up to the GitHub repo.
The other option is if I don't have anything done yet, I don't have a repo anywhere.
I know I want to start a project and I know right out of the gate that I also want to use GitHub alongside
Git.
If that's the case, I can start on GitHub, make a new repo on GitHub and clone that down to my machine
as an empty repository.
Instead of running git init I can clone down my github repo that's empty and start working in that repo
and then push it up to GitHub.
And if I do it that way, I don't have to manually connect my local repo to my GitHub repo because if
I clone this repo from GitHub, it automatically is connected to that GitHub URL.
So some diagrams to illustrate that.
I don't have any repositories yet either on GitHub or on my machine.
And I start by making a new repo on GitHub, which I'm visualizing is this empty container, and then
I clone that down to my laptop.
And because it came from this clone, it automatically knows about this GitHub URL.
So now I can do my work locally and push it up.
I don't have to connect them in any way, but I'm going to actually start by showing you the other option.
Option one, because you may have some existing code.
I mean, we certainly have existing repos from the course.
None of them are very useful, but we have existing repos.
Right.
We've been working with Git and let's talk about how to get that on GitHub.
So to do that, the first step is to make an empty GitHub repo.
So if you want to follow along, start by just picking some git repository that we've made or that you've
made that you want to get on GitHub.
So it doesn't have to be something that you make public and it doesn't have to be something that you
keep up there, right?
You can delete it or get rid of it immediately if you don't want people to see it.
So we've done quite a few different repositories.
Why don't I just take that really simple book repository?
My first novel.
All right.
So it's a disastrous repo.
I'd like to get all of this up on GitHub.
All right.
All this history, all my files.
One more time.
This is what I'm dealing with.
So whatever you have found, if you have a repo you want to follow along with, the first step is to
go on GitHub.
So once you're signed in and create a new empty repo and there's a couple of buttons to do that, one
is just this green button if you're on the home page new or if you're somewhere else like I'm on Marketplace.
If I click the plus new repo right there, then I see this page create a new repository.
So we need to come up with a name about GitHub, demo, novel or something like that.
This is just a name that we'll use to identify it on GitHub, right?
It doesn't have to match anything from our actual repository that we have locally, but we don't want
spaces.
It will automatically add dashes for us.
I don't know, I just put them in there myself.
But we don't need to do that.
You don't really need a description, although you should put one in, especially if you plan on having
other people see this repo or discover it.
But we will talk more about that to keep this short and simple.
I'm not going to put a description in there and then we can decide if it's public or private.
Now, I'm going to keep this public in case some of you want to take a look at the repo, although,
frankly, for the contents of this book, it's probably best for my reputation if I do make it private.
That just means that if someone looks at my profile, if they search, they're not going to find this
repository.
They don't have access to it.
But if it's public, anyone can see it.
And then I'm not going to touch this.
We will come back and talk more about these files later.
I'm just going to click Create Repository.
And did I click?
I might have not.
I guess I didn't click.
And we now see this page here.
So my username, Colt Slash and then the repository name, and then inside of it.
There's not really anything to look at right now except for a couple of instructions.
All right, so I'll stop here.
We've made an empty GitHub repository.
Our local repo knows nothing about it.
They're not connected in any way, but that's going to change in the next video.