1 00:00:00,120 --> 00:00:00,480 All right. 2 00:00:00,480 --> 00:00:05,970 So next step, I want to talk a little bit more about how push works and specifically the relationship 3 00:00:05,970 --> 00:00:10,320 between a branch that we have locally and then a branch on GitHub. 4 00:00:10,680 --> 00:00:16,950 So to begin with, I'm just going to make a new repository to demonstrate this with a new GitHub repository. 5 00:00:16,950 --> 00:00:20,400 I'm just going to call this push me. 6 00:00:20,400 --> 00:00:27,150 Sure, I'll make it public, I'll create it, and then I'll just copy this line to add the remote. 7 00:00:28,350 --> 00:00:32,820 And now I'm going to make a new repository locally. 8 00:00:33,360 --> 00:00:34,860 I don't have anything going on here. 9 00:00:35,100 --> 00:00:38,610 I'm going to get an IT and then I'll just make a file here. 10 00:00:38,610 --> 00:00:41,190 How about candy? 11 00:00:42,180 --> 00:00:42,690 Sure. 12 00:00:43,920 --> 00:00:45,690 Oh, jeez, I forgot to touch it. 13 00:00:46,680 --> 00:00:53,610 Okay, so I'm going to add that empty file and I'm going to commit create candy file. 14 00:00:53,910 --> 00:00:54,570 All right. 15 00:00:54,570 --> 00:00:57,060 So I'm going to add this remote, right? 16 00:00:57,060 --> 00:00:57,930 We've seen this before. 17 00:00:57,960 --> 00:01:01,920 Get remote, add origins, the URL for that GitHub repository. 18 00:01:02,190 --> 00:01:08,250 Now, when I run this command, if I want to push up my master branch, get push origin master. 19 00:01:08,940 --> 00:01:13,710 What this does, as we've already talked about, is it pushes up my master branch, whatever commits 20 00:01:13,710 --> 00:01:15,570 are on it up to GitHub. 21 00:01:15,570 --> 00:01:21,810 But what is really important to understand is that this will actually create a master branch on GitHub 22 00:01:21,810 --> 00:01:23,220 the very first time. 23 00:01:23,220 --> 00:01:23,460 Right? 24 00:01:23,490 --> 00:01:28,980 There is no branch on GitHub at the moment and there is a branch called Master locally. 25 00:01:29,370 --> 00:01:32,730 So it's going to create a new master branch on GitHub. 26 00:01:33,660 --> 00:01:38,160 And then I have my local master branch and they're connected, as you can see, by this little arrow. 27 00:01:38,160 --> 00:01:38,970 It shows me. 28 00:01:39,000 --> 00:01:41,640 It just says master, pointing to master. 29 00:01:42,180 --> 00:01:46,530 This is something we're going to learn more about in the next section when we talk about fetching and 30 00:01:46,530 --> 00:01:47,190 pulling. 31 00:01:47,460 --> 00:01:52,380 But there's a distinction between the branches you have locally and the branches on GitHub, if I refresh 32 00:01:52,380 --> 00:01:52,830 here. 33 00:01:53,700 --> 00:01:54,250 There we are. 34 00:01:54,270 --> 00:01:57,240 We see the master branch and I see this empty candy file. 35 00:01:57,450 --> 00:02:06,570 Now, usually, well, a lot of the time we want to connect and push our master branch up to the master 36 00:02:06,570 --> 00:02:09,840 branch on GitHub, but we don't have to. 37 00:02:10,050 --> 00:02:11,430 So I want to be very clear about that. 38 00:02:11,430 --> 00:02:14,640 If I do more work here, let's just make another file. 39 00:02:14,670 --> 00:02:19,920 Touch candy and flowers, dot text. 40 00:02:20,370 --> 00:02:26,010 I'll add that and I'll commit m create flowers. 41 00:02:27,750 --> 00:02:34,680 If I do a get push origin master again, this time it doesn't make a new branch called Master on GitHub. 42 00:02:34,680 --> 00:02:35,670 It's already here. 43 00:02:35,670 --> 00:02:40,770 So it's just going to push our master branch to this master branch on GitHub. 44 00:02:40,770 --> 00:02:42,300 It just assumes that's what we want. 45 00:02:42,300 --> 00:02:43,470 That's what we've told it. 46 00:02:43,470 --> 00:02:51,300 If you just specify this, just a single branch name, master, it's going to it get is going to take 47 00:02:51,300 --> 00:02:55,770 our local master branch and push it up to the remote master branch. 48 00:02:56,190 --> 00:02:57,600 So we'll see that. 49 00:02:59,040 --> 00:03:00,330 Hopefully no surprise. 50 00:03:00,420 --> 00:03:07,470 And we see this second file, our second commit show up, but we can actually push to different branches. 51 00:03:07,800 --> 00:03:13,170 So this syntax is not that crazy looking, but right here it's a little bit intimidating when I write 52 00:03:13,170 --> 00:03:15,390 it out with the official definition. 53 00:03:15,930 --> 00:03:22,410 Basically, if we write, get push and then a remote like origin and then I specify a local branch, 54 00:03:22,440 --> 00:03:24,960 a colon and a remote branch. 55 00:03:24,960 --> 00:03:29,970 This would enable me to push a local branch to a remote branch of a different name. 56 00:03:30,060 --> 00:03:33,510 So take the local pancake branch. 57 00:03:33,510 --> 00:03:39,420 That one goes first local on my machine and push it to the origins branch called Waffle. 58 00:03:39,600 --> 00:03:40,830 So I'm going to demonstrate this. 59 00:03:40,830 --> 00:03:45,900 It's nowhere near as common, but I do want to make it clear that there's a distinction. 60 00:03:46,080 --> 00:03:47,640 They don't have to be the same. 61 00:03:47,640 --> 00:03:52,020 You don't have to push master up to master, even though that's the default behavior. 62 00:03:52,020 --> 00:03:54,570 If you just run, get push origin master. 63 00:03:54,660 --> 00:03:56,580 So why don't I make a new branch? 64 00:03:57,420 --> 00:03:58,560 What should this one be called? 65 00:03:58,560 --> 00:03:59,490 How about cats? 66 00:04:00,570 --> 00:04:04,950 So I have this new branch called cats and I'm going to make some changes on it. 67 00:04:05,010 --> 00:04:12,210 Like just add, I guess we'll just make a cats file and no, this is quite the boring repository. 68 00:04:12,210 --> 00:04:13,500 Let's add cats. 69 00:04:13,800 --> 00:04:15,060 I'm on this branch. 70 00:04:15,060 --> 00:04:15,330 Right. 71 00:04:15,330 --> 00:04:16,980 So create Cat's file. 72 00:04:16,980 --> 00:04:18,540 I'm on the cats branch. 73 00:04:18,810 --> 00:04:26,850 If I do a get push origin cats that will push up my local cats branch to a branch on origin that doesn't 74 00:04:26,850 --> 00:04:27,390 exist yet. 75 00:04:27,390 --> 00:04:29,520 It will create it called cats. 76 00:04:29,820 --> 00:04:34,170 But if I instead I don't want that to happen, which I'll just do it first. 77 00:04:34,170 --> 00:04:36,870 So you see that just more practice, right? 78 00:04:37,200 --> 00:04:38,760 The master branch is unchanged. 79 00:04:38,760 --> 00:04:43,110 We don't see cats, but if I go to the cats, branch can toggle them. 80 00:04:43,110 --> 00:04:46,470 Here we see the cats file anyway. 81 00:04:46,710 --> 00:04:50,310 If I instead want to get that work on master. 82 00:04:50,460 --> 00:04:53,130 Not a normal thing to do, but I'm just going to show this. 83 00:04:53,130 --> 00:05:01,230 If I do get push origin and then my local branch cats and then the destination branch on the remote. 84 00:05:01,230 --> 00:05:07,830 This is the syntax local branch that we have on our machine colon and then the name of a branch on GitHub. 85 00:05:07,830 --> 00:05:11,070 So Master or if we had some other branch on GitHub. 86 00:05:11,070 --> 00:05:16,170 Sure, this tells gets to take our local cat's branch and push it up to the origin master branch. 87 00:05:16,170 --> 00:05:16,950 Let's try it. 88 00:05:19,280 --> 00:05:19,880 Okay. 89 00:05:19,880 --> 00:05:21,270 And we see this diagram. 90 00:05:21,290 --> 00:05:23,460 It's not a diagram, really, but we see this. 91 00:05:23,480 --> 00:05:28,850 It says or it tells us it pushed the cat's branch to the master branch this time. 92 00:05:28,850 --> 00:05:33,500 So if I refresh now on the master branch on GitHub, we see that cats file. 93 00:05:33,650 --> 00:05:39,410 Even though we didn't push the master branch from our machine up, we pushed the cat's branch, but 94 00:05:39,410 --> 00:05:42,620 we pushed it to the GitHub master branch. 95 00:05:42,620 --> 00:05:48,020 So I know that's kind of confusing and again, not at all common, but you can do it. 96 00:05:48,020 --> 00:05:53,120 And I just showed it to you to make it clear that there's a distinction between the branch on your machine 97 00:05:53,120 --> 00:05:54,350 and the branch on GitHub. 98 00:05:54,350 --> 00:06:00,380 And when we normally do things like this, get Push Origin Master Yes, we're pushing the master branch 99 00:06:00,380 --> 00:06:03,080 from our machine to the master branch on GitHub. 100 00:06:03,080 --> 00:06:07,610 Normally we want them to be the same, but they don't have to be all right.