1 00:00:00,120 --> 00:00:06,930 One more thing to talk about with git push is the new option, which you've likely seen when you create 2 00:00:06,930 --> 00:00:12,000 a new branch or a branch, when you create a new repository, which I won't actually. 3 00:00:12,240 --> 00:00:15,300 Well, I guess I kind of have to if I want to show you. 4 00:00:15,780 --> 00:00:17,010 Okay, I'll delete this one. 5 00:00:17,010 --> 00:00:18,780 But if I make a new repository. 6 00:00:19,760 --> 00:00:23,540 The instructions GitHub gives me both of them end with this line. 7 00:00:23,540 --> 00:00:26,720 Get push something with a dash you. 8 00:00:26,960 --> 00:00:29,230 So what is this dash you option? 9 00:00:29,240 --> 00:00:33,350 Well, it stands for upstream, which probably doesn't mean a lot. 10 00:00:33,920 --> 00:00:40,760 The upstream of a branch, a local branch is kind of like think of it as a connection, pointing to 11 00:00:40,760 --> 00:00:41,930 a remote branch. 12 00:00:41,930 --> 00:00:49,820 So if we have our master branch on our local machine, normally we want the upstream branch to be origin 13 00:00:49,820 --> 00:00:52,370 master or some master branch on GitHub. 14 00:00:53,180 --> 00:00:59,960 They are connected and this enables me to do things like just run git push without having to specify 15 00:00:59,960 --> 00:01:07,850 Origin Master and if I've configured the upstream for my master branch then I get to use this shortcut. 16 00:01:08,090 --> 00:01:12,950 So there are other situations where this comes up as well, like with polling when we talk about that. 17 00:01:13,070 --> 00:01:17,960 But again, it's not something that we have to do in order to push, but it's recommended because it 18 00:01:17,960 --> 00:01:19,370 can make your life easier. 19 00:01:19,460 --> 00:01:26,480 So when we run this, get pushed dash you origin master this tells git that on my computer locally in 20 00:01:26,480 --> 00:01:35,030 my repo I want to push up the master branch to Origin Master and I want you to remember that. 21 00:01:35,030 --> 00:01:41,180 I want you to recall in the future that my master branch on my computer is connected to the master branch 22 00:01:41,180 --> 00:01:41,930 on origin. 23 00:01:42,620 --> 00:01:47,930 So if I do this right now, let's see if I make a new branch on this example we were doing. 24 00:01:48,170 --> 00:01:50,930 Let's make a new branch called dogs. 25 00:01:51,620 --> 00:01:52,220 All right. 26 00:01:52,220 --> 00:01:54,680 So this branch right now does not exist on GitHub. 27 00:01:55,250 --> 00:01:58,670 If I push it up, get push origin dogs. 28 00:02:01,020 --> 00:02:06,060 You can see it's not here, but it will make a new dog's branch on GitHub. 29 00:02:06,090 --> 00:02:07,170 There it is. 30 00:02:08,910 --> 00:02:11,070 But I did not set the upstream. 31 00:02:11,370 --> 00:02:11,970 Right. 32 00:02:12,000 --> 00:02:14,580 I did not use that dash you option. 33 00:02:14,590 --> 00:02:15,650 But that's okay. 34 00:02:15,660 --> 00:02:21,240 If I want to push up again, whatever I have on this dog's branch, let's make a change. 35 00:02:21,240 --> 00:02:22,650 Let's make a new file. 36 00:02:22,710 --> 00:02:26,010 Dogs that text get add, dogs get, commit. 37 00:02:26,010 --> 00:02:29,510 Just an empty file create dogs. 38 00:02:29,520 --> 00:02:34,640 If I want to push that up, I have to do get push origin dogs. 39 00:02:34,650 --> 00:02:35,850 That's totally fine. 40 00:02:35,850 --> 00:02:36,840 It's not a big deal. 41 00:02:37,290 --> 00:02:43,170 But normally I want my dog's branch to be connected to the GitHub dogs branch. 42 00:02:43,170 --> 00:02:43,300 Right. 43 00:02:43,320 --> 00:02:45,240 I want this connection right here. 44 00:02:45,240 --> 00:02:47,070 Dog's pointing to dogs. 45 00:02:47,070 --> 00:02:52,020 My local dogs branch connected to the GitHub dogs branch on origin. 46 00:02:52,020 --> 00:02:53,250 That's standard. 47 00:02:53,250 --> 00:02:58,080 In the previous video I showed you that you can push from one branch to something with a different name, 48 00:02:58,080 --> 00:02:59,730 but normally we want them connected. 49 00:02:59,730 --> 00:03:03,360 And if I use this dash view that will enable it to happen. 50 00:03:03,360 --> 00:03:07,410 But before that, if I just try git push you'll see it fails. 51 00:03:07,410 --> 00:03:12,510 It says the current branch does not have or current branch dogs has no upstream branch. 52 00:03:12,510 --> 00:03:14,400 So here's one way to do this. 53 00:03:14,490 --> 00:03:18,900 Dash dash set upstream or we just use dash you, which is equivalent. 54 00:03:19,380 --> 00:03:24,570 So I'm going to do that now get push dash you origin dogs. 55 00:03:24,900 --> 00:03:29,850 So remember, if we don't use this weird colon syntax that I showed you in the previous video. 56 00:03:30,810 --> 00:03:35,280 Get is going to take our local dogs branch and push it up to the origin dogs branch. 57 00:03:35,280 --> 00:03:40,080 It uses the same name and this dash you says, I want you to remember that. 58 00:03:40,410 --> 00:03:43,920 Set the upstream for dogs to be origin dogs. 59 00:03:44,040 --> 00:03:51,000 And now it shows me this line right here, branch dogs set up to track remote branch dogs from Origin. 60 00:03:51,210 --> 00:03:54,840 So now if I make a change, let's just make a new file. 61 00:03:55,500 --> 00:04:03,780 Touch more dogs get add more dogs get commit create more dogs. 62 00:04:03,900 --> 00:04:06,990 If I do, just get push in nothing else. 63 00:04:07,200 --> 00:04:14,370 Now we have an upstream set and it knows for this dog's branch that I'm on what that upstream is and 64 00:04:14,370 --> 00:04:20,070 it pushes up to my GitHub dog's branch and we see more dogs showing up here. 65 00:04:20,250 --> 00:04:21,510 So that's the use case for Dash. 66 00:04:21,510 --> 00:04:28,710 You normally you'll use it in this context, but you could use it in a situation like this if you wanted 67 00:04:28,710 --> 00:04:33,600 to set the upstream to be something other than the remote branch of the same name. 68 00:04:33,600 --> 00:04:41,640 In other words, if I wanted to set, I'm not going to do this, but if I wanted to set the dogs branch 69 00:04:41,640 --> 00:04:47,670 locally, I wanted to push that up to the Cats branch and set that upstream. 70 00:04:47,670 --> 00:04:48,390 I can. 71 00:04:48,390 --> 00:04:55,080 So if I ran this, not only would it push my dog's branch from my machine up to the remote Cats branch 72 00:04:55,080 --> 00:04:55,800 on GitHub. 73 00:04:55,800 --> 00:05:02,280 It would also say in the future this dogs branch should have an upstream referring to the Origin Cats 74 00:05:02,280 --> 00:05:02,880 branch. 75 00:05:03,300 --> 00:05:07,650 Normally you don't want that and also it can be a headache and I don't recommend you try this stuff. 76 00:05:08,130 --> 00:05:09,630 You'll run into like merging issues. 77 00:05:09,630 --> 00:05:15,330 If you're pushing from multiple branches to the same remote branch, the cats branch is just you don't 78 00:05:15,330 --> 00:05:17,010 want to do it anyway. 79 00:05:17,160 --> 00:05:20,490 It's possible, but normally you'll use it in this context. 80 00:05:20,490 --> 00:05:27,660 The very first time you push some branch up, use that dash you and the local branch of that name will 81 00:05:27,660 --> 00:05:32,400 have its upstream set to the origin branch of that name or whatever this remote is called. 82 00:05:32,640 --> 00:05:33,270 All right.