One more thing to talk about with git push is the new option, which you've likely seen when you create
a new branch or a branch, when you create a new repository, which I won't actually.
Well, I guess I kind of have to if I want to show you.
Okay, I'll delete this one.
But if I make a new repository.
The instructions GitHub gives me both of them end with this line.
Get push something with a dash you.
So what is this dash you option?
Well, it stands for upstream, which probably doesn't mean a lot.
The upstream of a branch, a local branch is kind of like think of it as a connection, pointing to
a remote branch.
So if we have our master branch on our local machine, normally we want the upstream branch to be origin
master or some master branch on GitHub.
They are connected and this enables me to do things like just run git push without having to specify
Origin Master and if I've configured the upstream for my master branch then I get to use this shortcut.
So there are other situations where this comes up as well, like with polling when we talk about that.
But again, it's not something that we have to do in order to push, but it's recommended because it
can make your life easier.
So when we run this, get pushed dash you origin master this tells git that on my computer locally in
my repo I want to push up the master branch to Origin Master and I want you to remember that.
I want you to recall in the future that my master branch on my computer is connected to the master branch
on origin.
So if I do this right now, let's see if I make a new branch on this example we were doing.
Let's make a new branch called dogs.
All right.
So this branch right now does not exist on GitHub.
If I push it up, get push origin dogs.
You can see it's not here, but it will make a new dog's branch on GitHub.
There it is.
But I did not set the upstream.
Right.
I did not use that dash you option.
But that's okay.
If I want to push up again, whatever I have on this dog's branch, let's make a change.
Let's make a new file.
Dogs that text get add, dogs get, commit.
Just an empty file create dogs.
If I want to push that up, I have to do get push origin dogs.
That's totally fine.
It's not a big deal.
But normally I want my dog's branch to be connected to the GitHub dogs branch.
Right.
I want this connection right here.
Dog's pointing to dogs.
My local dogs branch connected to the GitHub dogs branch on origin.
That's standard.
In the previous video I showed you that you can push from one branch to something with a different name,
but normally we want them connected.
And if I use this dash view that will enable it to happen.
But before that, if I just try git push you'll see it fails.
It says the current branch does not have or current branch dogs has no upstream branch.
So here's one way to do this.
Dash dash set upstream or we just use dash you, which is equivalent.
So I'm going to do that now get push dash you origin dogs.
So remember, if we don't use this weird colon syntax that I showed you in the previous video.
Get is going to take our local dogs branch and push it up to the origin dogs branch.
It uses the same name and this dash you says, I want you to remember that.
Set the upstream for dogs to be origin dogs.
And now it shows me this line right here, branch dogs set up to track remote branch dogs from Origin.
So now if I make a change, let's just make a new file.
Touch more dogs get add more dogs get commit create more dogs.
If I do, just get push in nothing else.
Now we have an upstream set and it knows for this dog's branch that I'm on what that upstream is and
it pushes up to my GitHub dog's branch and we see more dogs showing up here.
So that's the use case for Dash.
You normally you'll use it in this context, but you could use it in a situation like this if you wanted
to set the upstream to be something other than the remote branch of the same name.
In other words, if I wanted to set, I'm not going to do this, but if I wanted to set the dogs branch
locally, I wanted to push that up to the Cats branch and set that upstream.
I can.
So if I ran this, not only would it push my dog's branch from my machine up to the remote Cats branch
on GitHub.
It would also say in the future this dogs branch should have an upstream referring to the Origin Cats
branch.
Normally you don't want that and also it can be a headache and I don't recommend you try this stuff.
You'll run into like merging issues.
If you're pushing from multiple branches to the same remote branch, the cats branch is just you don't
want to do it anyway.
It's possible, but normally you'll use it in this context.
The very first time you push some branch up, use that dash you and the local branch of that name will
have its upstream set to the origin branch of that name or whatever this remote is called.
All right.