1 00:00:00,270 --> 00:00:00,720 Okay. 2 00:00:00,720 --> 00:00:03,760 So let's talk about how we actually get our code up on GitHub. 3 00:00:03,780 --> 00:00:07,410 How do we take a local git repo on our laptop? 4 00:00:07,800 --> 00:00:12,840 And how do I connect that in some way to a hosted GitHub repo? 5 00:00:12,870 --> 00:00:14,010 How do I connect them? 6 00:00:14,310 --> 00:00:15,960 How do I set up the repo on GitHub? 7 00:00:15,960 --> 00:00:19,680 And then what do I do on my machine to tell it about the GitHub repo? 8 00:00:20,010 --> 00:00:24,660 Well, there's really two different approaches or two options that I'm going to walk through in this 9 00:00:24,660 --> 00:00:25,350 video. 10 00:00:25,650 --> 00:00:31,020 I'm just going to talk about both of them and just explain how they work and then we'll dive into actually 11 00:00:31,020 --> 00:00:31,740 doing them. 12 00:00:31,860 --> 00:00:39,960 So the first option called option one is if you have an existing repo on your machine, if you have 13 00:00:39,960 --> 00:00:44,100 something that you've already been working on, it already has git history, you already have code, 14 00:00:44,100 --> 00:00:46,860 whatever it is, and you want to get that on GitHub. 15 00:00:46,890 --> 00:00:48,780 These would be the steps that you follow. 16 00:00:48,810 --> 00:00:55,670 You create a new repo on GitHub, then you connect your local repo by adding something called a remote. 17 00:00:55,680 --> 00:00:56,820 We'll go into that. 18 00:00:57,240 --> 00:01:03,120 So you add that remote to your local machine and then you push your changes up to GitHub. 19 00:01:03,660 --> 00:01:05,400 So here's some diagrams. 20 00:01:05,400 --> 00:01:10,620 If I have something I've been working on, whether it's just a day of work, an hour of work, an empty 21 00:01:10,620 --> 00:01:16,710 repository that I've created or years of work, whatever it is, if it's on my machine and not on GitHub, 22 00:01:17,010 --> 00:01:21,180 I go on to GitHub and I make a new empty repository. 23 00:01:21,810 --> 00:01:23,520 I'll show that in just a moment to. 24 00:01:23,880 --> 00:01:29,220 So once I make that new empty repository, then what I do is tell my computer. 25 00:01:29,220 --> 00:01:34,290 Specifically tell this git repository about the GitHub repository. 26 00:01:35,190 --> 00:01:38,670 And then I can push my code up to the GitHub repo. 27 00:01:39,500 --> 00:01:44,960 The other option is if I don't have anything done yet, I don't have a repo anywhere. 28 00:01:44,990 --> 00:01:50,900 I know I want to start a project and I know right out of the gate that I also want to use GitHub alongside 29 00:01:50,900 --> 00:01:51,440 Git. 30 00:01:51,470 --> 00:01:59,210 If that's the case, I can start on GitHub, make a new repo on GitHub and clone that down to my machine 31 00:01:59,210 --> 00:02:01,160 as an empty repository. 32 00:02:01,160 --> 00:02:07,940 Instead of running git init I can clone down my github repo that's empty and start working in that repo 33 00:02:07,940 --> 00:02:09,590 and then push it up to GitHub. 34 00:02:09,590 --> 00:02:15,410 And if I do it that way, I don't have to manually connect my local repo to my GitHub repo because if 35 00:02:15,410 --> 00:02:20,700 I clone this repo from GitHub, it automatically is connected to that GitHub URL. 36 00:02:20,720 --> 00:02:22,940 So some diagrams to illustrate that. 37 00:02:22,940 --> 00:02:28,730 I don't have any repositories yet either on GitHub or on my machine. 38 00:02:28,730 --> 00:02:36,020 And I start by making a new repo on GitHub, which I'm visualizing is this empty container, and then 39 00:02:36,020 --> 00:02:38,300 I clone that down to my laptop. 40 00:02:38,510 --> 00:02:44,360 And because it came from this clone, it automatically knows about this GitHub URL. 41 00:02:44,480 --> 00:02:47,510 So now I can do my work locally and push it up. 42 00:02:47,720 --> 00:02:52,280 I don't have to connect them in any way, but I'm going to actually start by showing you the other option. 43 00:02:52,280 --> 00:02:55,730 Option one, because you may have some existing code. 44 00:02:55,730 --> 00:02:58,280 I mean, we certainly have existing repos from the course. 45 00:02:58,280 --> 00:03:02,480 None of them are very useful, but we have existing repos. 46 00:03:02,480 --> 00:03:02,680 Right. 47 00:03:02,690 --> 00:03:07,370 We've been working with Git and let's talk about how to get that on GitHub. 48 00:03:07,520 --> 00:03:12,230 So to do that, the first step is to make an empty GitHub repo. 49 00:03:12,380 --> 00:03:18,920 So if you want to follow along, start by just picking some git repository that we've made or that you've 50 00:03:18,920 --> 00:03:21,290 made that you want to get on GitHub. 51 00:03:21,290 --> 00:03:26,060 So it doesn't have to be something that you make public and it doesn't have to be something that you 52 00:03:26,060 --> 00:03:27,160 keep up there, right? 53 00:03:27,200 --> 00:03:31,280 You can delete it or get rid of it immediately if you don't want people to see it. 54 00:03:32,360 --> 00:03:35,830 So we've done quite a few different repositories. 55 00:03:35,850 --> 00:03:40,040 Why don't I just take that really simple book repository? 56 00:03:40,040 --> 00:03:41,390 My first novel. 57 00:03:42,020 --> 00:03:42,410 All right. 58 00:03:42,410 --> 00:03:45,050 So it's a disastrous repo. 59 00:03:45,980 --> 00:03:48,530 I'd like to get all of this up on GitHub. 60 00:03:49,070 --> 00:03:49,430 All right. 61 00:03:49,430 --> 00:03:51,590 All this history, all my files. 62 00:03:51,590 --> 00:03:52,340 One more time. 63 00:03:52,340 --> 00:03:53,420 This is what I'm dealing with. 64 00:03:53,420 --> 00:03:59,420 So whatever you have found, if you have a repo you want to follow along with, the first step is to 65 00:03:59,420 --> 00:04:00,410 go on GitHub. 66 00:04:00,560 --> 00:04:06,890 So once you're signed in and create a new empty repo and there's a couple of buttons to do that, one 67 00:04:06,890 --> 00:04:13,880 is just this green button if you're on the home page new or if you're somewhere else like I'm on Marketplace. 68 00:04:13,880 --> 00:04:20,839 If I click the plus new repo right there, then I see this page create a new repository. 69 00:04:20,839 --> 00:04:27,500 So we need to come up with a name about GitHub, demo, novel or something like that. 70 00:04:27,620 --> 00:04:32,450 This is just a name that we'll use to identify it on GitHub, right? 71 00:04:32,450 --> 00:04:37,760 It doesn't have to match anything from our actual repository that we have locally, but we don't want 72 00:04:37,760 --> 00:04:38,750 spaces. 73 00:04:39,110 --> 00:04:41,420 It will automatically add dashes for us. 74 00:04:41,600 --> 00:04:43,640 I don't know, I just put them in there myself. 75 00:04:43,640 --> 00:04:45,590 But we don't need to do that. 76 00:04:45,980 --> 00:04:50,990 You don't really need a description, although you should put one in, especially if you plan on having 77 00:04:50,990 --> 00:04:53,660 other people see this repo or discover it. 78 00:04:54,050 --> 00:04:57,230 But we will talk more about that to keep this short and simple. 79 00:04:57,770 --> 00:05:01,910 I'm not going to put a description in there and then we can decide if it's public or private. 80 00:05:02,180 --> 00:05:07,250 Now, I'm going to keep this public in case some of you want to take a look at the repo, although, 81 00:05:07,250 --> 00:05:14,120 frankly, for the contents of this book, it's probably best for my reputation if I do make it private. 82 00:05:14,120 --> 00:05:18,830 That just means that if someone looks at my profile, if they search, they're not going to find this 83 00:05:18,830 --> 00:05:19,820 repository. 84 00:05:19,940 --> 00:05:21,200 They don't have access to it. 85 00:05:21,200 --> 00:05:23,600 But if it's public, anyone can see it. 86 00:05:24,350 --> 00:05:25,910 And then I'm not going to touch this. 87 00:05:26,390 --> 00:05:29,510 We will come back and talk more about these files later. 88 00:05:29,510 --> 00:05:32,060 I'm just going to click Create Repository. 89 00:05:33,890 --> 00:05:35,420 And did I click? 90 00:05:35,600 --> 00:05:36,980 I might have not. 91 00:05:37,310 --> 00:05:38,780 I guess I didn't click. 92 00:05:38,930 --> 00:05:42,220 And we now see this page here. 93 00:05:42,230 --> 00:05:48,020 So my username, Colt Slash and then the repository name, and then inside of it. 94 00:05:48,020 --> 00:05:52,280 There's not really anything to look at right now except for a couple of instructions. 95 00:05:52,280 --> 00:05:53,390 All right, so I'll stop here. 96 00:05:53,390 --> 00:05:55,670 We've made an empty GitHub repository. 97 00:05:55,670 --> 00:05:58,520 Our local repo knows nothing about it. 98 00:05:58,520 --> 00:06:02,390 They're not connected in any way, but that's going to change in the next video.