1 00:00:00,150 --> 00:00:00,780 All right. 2 00:00:00,780 --> 00:00:06,510 So the next thing that we need to do is take this empty GitHub repo that's in the cloud. 3 00:00:06,510 --> 00:00:12,600 It's not connected at all to our local repo and somehow configure our local repo so that it knows about 4 00:00:12,600 --> 00:00:13,890 this GitHub repo. 5 00:00:14,310 --> 00:00:20,160 Well, the way that we do this, whether we're using GitHub or any other service that hosts the repo, 6 00:00:20,280 --> 00:00:23,010 is to set up a git remote. 7 00:00:23,250 --> 00:00:29,820 So a remote is really just a fancy name for like a destination URL. 8 00:00:29,850 --> 00:00:33,960 It's a URL that we tell get about and we give it a name. 9 00:00:34,350 --> 00:00:42,510 It's just like a label for a URL that we can then push code up to or fetch or pull down new code from. 10 00:00:42,750 --> 00:00:45,840 So we'll learn about those commands once we set up a remote. 11 00:00:46,080 --> 00:00:51,480 So an easy place to start is with this command git remote or get remote dash v. 12 00:00:51,480 --> 00:00:57,230 They won't do anything except list to you the current remotes that you have in a repository. 13 00:00:57,240 --> 00:01:01,290 So in our repository we have not configured any remotes. 14 00:01:01,290 --> 00:01:01,620 Right? 15 00:01:01,620 --> 00:01:02,310 At this point. 16 00:01:02,310 --> 00:01:03,720 We haven't done anything with remotes. 17 00:01:03,720 --> 00:01:10,950 If I type git remote or git remote V, I'm in my book, my first novel, The Great Gatsby repo nothing. 18 00:01:11,280 --> 00:01:17,250 But if we actually go to any of the repos that we cloned, if you follow a followed along, I cloned 19 00:01:17,250 --> 00:01:20,370 this 2048 repo from GitHub. 20 00:01:20,520 --> 00:01:28,140 Remember this one it has a whole bunch of commits it's that addicting 2048 game anyway if I type get 21 00:01:28,140 --> 00:01:34,110 remote in here I see something now origin we'll talk about that in a moment. 22 00:01:34,110 --> 00:01:36,600 Let's do dash v so you can see the difference. 23 00:01:36,630 --> 00:01:39,210 If I do dash v, I think it's verbose. 24 00:01:39,570 --> 00:01:44,580 We see the name of of a remote and the corresponding URL. 25 00:01:45,090 --> 00:01:47,580 So I didn't set this up right. 26 00:01:47,580 --> 00:01:55,350 All I did was get clone and then this URL and by doing that get made me a local repo. 27 00:01:55,380 --> 00:02:02,700 It put all these files in here, it gave me all the history and it set up a remote that said the original 28 00:02:02,730 --> 00:02:07,260 GitHub URL that this repo came from, that it was cloned from IS right here. 29 00:02:07,920 --> 00:02:15,090 So by setting this URL up, this remote origin, it gives me the ability later on to say, Hey, Git, 30 00:02:15,090 --> 00:02:17,280 is there any new code on that URL? 31 00:02:17,310 --> 00:02:19,710 Is there any new updates? 32 00:02:19,710 --> 00:02:25,670 Or if I was a collaborator, hey git, I'd like to push up my new ten commits. 33 00:02:25,680 --> 00:02:31,710 It's kind of a lot to push up, but I'd like to push my new two commits that I did today up to Origin. 34 00:02:32,820 --> 00:02:35,070 So I'll just show you one more example. 35 00:02:35,340 --> 00:02:43,500 If I take a look at that see sample project that was the one that I cloned in the second video I did. 36 00:02:43,500 --> 00:02:45,750 It's really very simple. 37 00:02:45,750 --> 00:02:46,320 Nothing in it. 38 00:02:46,320 --> 00:02:48,540 It came from was it Bitbucket? 39 00:02:48,540 --> 00:02:52,500 I believe if I do get remote V No, get lab. 40 00:02:52,500 --> 00:02:55,590 Sorry, it was a non github repository. 41 00:02:55,590 --> 00:02:57,060 The same thing is true. 42 00:02:57,060 --> 00:02:57,260 Right. 43 00:02:57,270 --> 00:02:59,940 I have a remote called origin automatically set up. 44 00:02:59,940 --> 00:03:05,760 I didn't do that and it set to whatever I cloned or whatever the URL is that I cloned it from. 45 00:03:06,240 --> 00:03:06,670 Okay. 46 00:03:06,840 --> 00:03:10,230 So we did not clone this repository, right? 47 00:03:10,230 --> 00:03:12,450 My first novel, we we ran getting it. 48 00:03:12,450 --> 00:03:13,890 We created it from scratch. 49 00:03:13,890 --> 00:03:21,210 So there are no remotes, but we can make a remote using this command, get remote add and then a name 50 00:03:21,210 --> 00:03:22,890 and a URL. 51 00:03:23,250 --> 00:03:26,220 So this is a way of telling git hello gets. 52 00:03:26,220 --> 00:03:29,460 Please remember this URL using this name. 53 00:03:29,460 --> 00:03:31,500 So whatever the name is that we provide. 54 00:03:32,100 --> 00:03:35,400 So a really standard name is origin. 55 00:03:35,430 --> 00:03:43,380 So get remote, add origin and then some github URL for a github repo that we've created is telling 56 00:03:43,380 --> 00:03:43,860 git. 57 00:03:43,890 --> 00:03:46,620 Hey, here's a URL, I'm going to call it origin. 58 00:03:46,620 --> 00:03:50,820 You remember that anytime I refer to origin, I'm talking about this URL. 59 00:03:51,330 --> 00:03:56,760 So the term origin, it's just a conventional git remote name, but it's not special in any way. 60 00:03:56,760 --> 00:03:58,350 No magical powers. 61 00:03:58,350 --> 00:04:00,450 It doesn't have any secret abilities. 62 00:04:00,450 --> 00:04:04,050 It's just a name for a URL you could rename them. 63 00:04:04,050 --> 00:04:08,760 You can come up with whatever names you want for remotes, but origin is what you'll see all the time, 64 00:04:08,880 --> 00:04:15,240 similar to how the master branch is a default name or the default name for branches, you can change 65 00:04:15,240 --> 00:04:15,990 it to anything. 66 00:04:15,990 --> 00:04:19,470 So in the same way that master is just a name for a branch origin. 67 00:04:19,470 --> 00:04:21,120 It's just a conventional name. 68 00:04:21,120 --> 00:04:24,630 You'll see it a lot, but it is not somehow special. 69 00:04:24,630 --> 00:04:26,280 It's just a name for a remote. 70 00:04:26,280 --> 00:04:34,920 So we could instead add a new remote for the same URL, but instead call it my github URL or lol or 71 00:04:34,920 --> 00:04:41,730 chickens are my friends, whatever you want, but I would suggest origin because it's what you'll see 72 00:04:41,730 --> 00:04:43,950 the most and then a URL. 73 00:04:44,070 --> 00:04:51,210 And actually if we go to the GitHub repository that we created that's empty, we see some instructions. 74 00:04:51,240 --> 00:04:55,710 It's telling us, first of all, if you've done this thing before, this kind of thing before, here's 75 00:04:55,710 --> 00:04:58,680 a URL that is the URL for my repo. 76 00:04:58,890 --> 00:04:59,880 I hope this goes to that. 77 00:04:59,990 --> 00:05:02,630 Saying you should be using your URL, right? 78 00:05:02,630 --> 00:05:08,300 Not my repo because you won't have permission to push your code up to my repository. 79 00:05:08,300 --> 00:05:09,430 So I hope you made your own. 80 00:05:09,440 --> 00:05:15,920 If you're following along then it's telling me if you don't have a repo yet on the like at all locally, 81 00:05:15,920 --> 00:05:17,060 follow these instructions. 82 00:05:17,060 --> 00:05:18,050 But I do. 83 00:05:18,200 --> 00:05:20,300 So I'm not following those. 84 00:05:20,900 --> 00:05:21,980 This is what we want. 85 00:05:21,980 --> 00:05:26,510 Push an existing repo from the command line and take a look at the very first line. 86 00:05:27,020 --> 00:05:32,630 Get remote, add origin and then the URL for my git repo. 87 00:05:32,660 --> 00:05:37,880 It's the same URL we see here, so I'm going to copy that or just copy the whole line. 88 00:05:37,880 --> 00:05:39,020 It doesn't really matter. 89 00:05:39,740 --> 00:05:43,610 I guess I'll separate it out just to hit the point harder here. 90 00:05:43,610 --> 00:05:47,040 So I'm on the my first novel repository right now. 91 00:05:47,060 --> 00:05:52,280 No remotes now get remote add and then a name. 92 00:05:52,280 --> 00:05:53,690 I'm going to go with origin. 93 00:05:53,690 --> 00:05:54,800 It's conventional. 94 00:05:55,160 --> 00:06:00,290 And then this GitHub URL, whatever your GitHub URL is for that repo. 95 00:06:00,950 --> 00:06:02,360 Now nothing really happens. 96 00:06:02,360 --> 00:06:06,800 But of course we can check our work with what we just saw get remote v. 97 00:06:07,070 --> 00:06:13,160 So hopefully we see origin set up to this URL and it is. 98 00:06:13,550 --> 00:06:16,340 So that's kind of all we need to do for now. 99 00:06:16,340 --> 00:06:17,180 We've connected. 100 00:06:17,180 --> 00:06:24,200 We've told our local git repo about a GitHub URL called Origin or that's the name that will refer to 101 00:06:24,200 --> 00:06:24,800 it by. 102 00:06:24,830 --> 00:06:29,150 So in the next video, I'll show you how we can push code up to origin. 103 00:06:29,150 --> 00:06:36,800 I just want to emphasize one more time, it's just a name for a URL, a remote destination, and this 104 00:06:36,800 --> 00:06:43,310 is not super common, but if needed you can rename a remote with this command, get remote, rename 105 00:06:43,340 --> 00:06:49,730 the old name, space, new name and you can get rid of a remote with git remote remove and then the 106 00:06:49,730 --> 00:06:51,290 name that you're trying to delete. 107 00:06:51,290 --> 00:06:57,320 And later on we'll actually see that it's somewhat common to have multiple remotes, especially when 108 00:06:57,320 --> 00:06:59,360 you're working on open source projects. 109 00:06:59,750 --> 00:07:03,860 We'll talk about workflows and how that would work when we get to that section. 110 00:07:03,980 --> 00:07:04,460 Okay.