YTread Logo
YTread Logo

Git Pull Requests explained - Computer Stuff They Didn't Teach You #5

Jun 08, 2021
Hello friends, I'm Scott Hanselman, yesterday I did a basic git analysis or got 101 with my perspective on how you can learn git and today based on your comments I'm going to talk a little bit about

pull

requests

or PR that someone often says , send me. a PR or you would look at this

pull

request or you could merge my pull

requests

. It turns out that pull requests aren't really a git thing, it's just a convention, it's confusing because you think it's part of git, but it's actually a way of working. with git now yesterday, if I switch to our image in image, we stopped having created a bunch of text files, we had a record of the different jobs we did with our git repository and it was using Visual Studio code plus an additional extension . called git History which is lovely and git History lets you see your repository graphically and we created some text files and branched out into a parallel universe, a couple of them were called testing and then we merged back into the main one. line and did some work now a pull request is actually just someone else's branch in another world on your

computer

in a remote world it could be your

computer

it could be somewhere else one of the interesting things about get is where Is the code authorized?
git pull requests explained   computer stuff they didn t teach you 5
Authorized code is whatever you decide, git is what is called decentralized source control, so there is no rule that says my code is more important than yours. You could have a copy of my repository or a clone of it doing your thing and that's it. It's up to us as a team to decide the convention on what is the official authorized code and a pull request. I alone express my interest in you looking at my code and possibly leaving it at your side. It is a request to join your branch. my world now it's also worth noting that when I created this repository I created it locally and

didn

't do anything with github or get lab, this is a git repository that's just cooling down on my machine, it has nothing to do with the shape yet I know there are no remotes, the concept of remote connection in my kit doesn't exist sometimes, usually if I were to go up here and create a new repository, let's try this.
git pull requests explained   computer stuff they didn t teach you 5

More Interesting Facts About,

git pull requests explained computer stuff they didn t teach you 5...

I'm going to upload to another folder and I'm going to create a new repository and I'm going to call it I'm going to call it learning, okay. I'll do it first on github. That's not what I did yesterday. Yesterday I made a git repository. I

didn

't even speak. about github here i will do it on github. You could set up a readme file and some different ones don't create a readme file. I guess why not set a license which is probably the most responsible thing to do and you could also choose a language that I might be interested in getting ignores.
git pull requests explained   computer stuff they didn t teach you 5
I'll talk about that in another video and create this repository. This is creating the repository on github in the cloud. It's not on my computer. I can click on the code and I can check this code. I'm just going to copy this to the clipboard here, so I checked this URL, so my repository is a URL. I'm going to come back here and say git clone and then go to the right. -Click and paste on that location, so I say: Hey, can I have the repository called learning? Let's accept clone in learning. Getting to that is a folder.
git pull requests explained   computer stuff they didn t teach you 5
There's the first one from yesterday. Here is today's. And there is that license that is ignored and. that readme file is fine, so I brought a Git repository for myself. I cloned it. I made a copy. Now it's in two places. It's on GitHub. It's on my computer. What is the official one? What is the boss? It depends on who decides. It's probably fair to say that this. one, the github copy is the official source, but I might decide I want this to be the official source. There is nothing in get that says otherwise, it is me or my team who design.
Now remember when we said get remote control if I say get remote control, I say. the command gets the remote subcommand and the subcommands show it says something called origin, what is that? Get commit show origin says hey there is a named place we just call it origin it is a convention like master or main as convention get remote show origin started here it is just a name you may also see other names like upstream so which would imply that I'm downstream, okay, there's a fetch URL for a place to pull from and in this case it's also the same place I could push my code from.
Now, if we go back to where we were yesterday learning it and I say git remote show or get remote show origin, well, there's no origin. I couldn't read from a remote repository, that's because when you check into it or create a repository locally. As we did yesterday in the video one that I encourage you to watch, you will see that there is no remote control. I got that remote for free when I cloned the one I made on github now if we go back to my main page. on github and I made a repository and we call it, let's say learning, it gets the same name as we did yesterday, okay, we'll create it and then it says wait a second, are you doing this for the first time?
Want? It is giving me commands that I can get. I could add a file, but look at this line right here git remote add source. Okay, that's interesting, you can push an existing repository to the command line, so I said git remote show don't get remote add get remote shows I don't have one, there's no connection between my git and the one on the cloud, so let's try to copy and paste this just the first line. I'm going to hit alt tab here. I'll right click and Press Enter, nothing happens, but I'll confirm that it worked because git remote show and more specifically, get the source of the remote program, now see learn how to get.
Now I have connected a relationship. I've logged in,

they

get locally with the git remote, except on my local. machine or five text files and the one in the cloud there is nothing now here it says get push - you source master. I can go and learn what these things mean by saying git push or get remote or whatever and I can say - - help and that will go and start a web browser and take me there and I can find out what... remember saying hey, I'd like to that you said push... you that... you mean this concept called upstream, this allows me to trace the relationships between branches, remember how I said I'm downstream, now here it says I should push it to a branch called master, but if you remember yesterday I called mine master, you can call yours trunk or development or production or staging, whatever makes you happy, so I don't want to say get push origin master.
I'm going to say get push origin origin main now, before I do that, before I hit enter. I'm going to split the screen here and bring this here. So what I'm doing is pressing the Windows key on my Windows machine. I'm saying Windows right and left using the button on my keyboard marked Windows and now I'm going to press Enter on the left side here. okay, here we are going to configure the main remote branch to track the remote branch, it means great, so there is a relationship here now, okay, now here on this side and this browser here.
I'm going to hit refresh, look at that and that cool thing we took. an existing git repository and now we have it talking to the github one, so that's pretty cool. We can see that we have a branch called main. Also, I can see that there are seven commits in seven commits that look a lot like these commits. now the only difference is that I have other local branches here, okay, I have local branches that are not necessarily in the cloud, okay, up here I have the master branch. I could save all the branches for you, but there is nothing on github that knows my branches like the ones we made yesterday are called test or new feature, so I can say git branch - a and I can see locally here on my machine that I have main.
I have a new feature. I have proof. Those from yesterday and now I have a remote tracking branch, this remote origin called main, so it's pretty interesting. If you wanted, you could push these other branches to the cloud. I could change there and have people work on them, but it's very common in the get world for someone to be doing some work locally here on their own machine, for example, if you were to clone my get repository yourself on your machine, you can To do so, you would actually fork it. or split the world into a parallel universe, your copy of learning it and then doing some

stuff

, maybe make a branch, you could call it PR one if you don't feel like it, there's nothing wrong with that and you could make a pull request, then you could tell me. via github or any other way, hey, it would be great if you went and looked at my code.
Can I request that you extract my code? Wouldn't it be nice now if someone could do it? I could do it myself here if I wanted to, I could say create a pull request, but I don't have anything to necessarily compare. I don't really have a good way to do it because it's like, "Well, can you compare different branches? How would I do a pull request if?" I'm not someone else, so I need a friend to make a pull request for me, so I'll do it right now. I'm going to have someone make a copy of this and then make a pull request so you guys have a few minutes. happened and I can see that a fork has occurred and I can click on that and I can see that my friend Maggy has made a fork, a copy of her own copy of the learning march repository.
I can click on that and you'll see it's Ella, your L, she's doing her thing. She may have her own code, but I can see that a pull request arrived just a few minutes ago. Maggie said, Hey, can you go look at some code I made for you? She loves me. To put that code in my space in my area, I can click on that inside github and you'll notice that it says Maggie wants to merge a commit into Hanselman main and look she called it Maggie patch one, she can name it whatever. she makes her happy because, again, pull requests are just a construct,

they

're just a way of thinking, she's like, hey, I have a repository here and you have a repository.
Could we merge these two repositories? So this is what I want to show you that she could merge the pull request into github, meaning she would use the tools in github and do a bunch of interesting work. I might say yes, can you push this to the base branch of that master branch if there were a lot of commits? you crush them into one commitment if you have like five things coming up you say yeah that's great just give me the right or if I had moved on to the future and Maggie hadn't talked to her in a week and she's like Oh shoot my

stuff

They're cool, but are they old or could you put them on the new stuff?
Could you make a new base? Did you override and then just reproduce the things I did in yours? We'll talk about that in another video. but I think it would be more interesting because it is very easy to click on the merge pull request. That's the point: how do we learn? What if we could see this locally and in doing so understand git better? Okay, so if we look on the left side here I could see Maggie's pull request, so she here she says switched to a new branch called Maggie patch main. What I did was I created a local one myself, okay, and then I'm going to go extract it because she requested a pole. so I'm going to pull from it, get notice, it doesn't say so handsome and it says Maggie and we're going to pull from her repository, not mine, to my branch, okay, cool, look at that, no, I could look at it, what's going on.
Okay, looks like she made a change. What is this here? A different date. We have this text file. Now I can open it in Notepad or I can open it anywhere that makes me happy, but I'm going to open it here and. I'm going to say copy, it looks like, oh look, there's a Maggie code. In this case, she added Maggie's evidence to a text file. Okay, so she made a change and now I can see it. Now I remember I can say "get the main clock". she's gone, I can say git checkout Maggie look now she's back, that's Maggie's branch, how did I get it?
Let's remember that I made a branch and pulled it from your git repository now it's local to me now, again, I could have done all this and just click merge, but again, that's driving a car with automatic shifting and we're learning a little to operate the stick to drive a car with manual transmission, okay, so now, if I wanted to, I could go and check main, so I'm back here. Maggie. The test has already passed me by. Now what we are gonna do? We will merge. We're like we did this at the end of video 1 and again, feel free to go back and refer to video 1.
What we're going to do is merge into Maggie's patch. I'm going to do this here at the top, I'm going to make it a little bit bigger, there we go, we're not going to fast forward, we'll talk about that for a minute, there you go. Now it brought me this, but look at this, my nice message has changed color now and it says: Hello, you have two new things and what is this? Those two new things need to be pushed to the origin somewhere else, so I'm going to go and say get push. I'm going to put them on the main menu.
I'm going to say get push and that source name again could be anything, it could be development, it could be a staging of the source as a convention. just conventions conventions are just ways people say and let's do it this way why was I first this is how it's okay we just need to know that these don'tthey're necessarily built in, they're just things that people decide like main or origin or patch of Maggie one, someone decided it and it's okay, so I want to push it, cool, what is this? check this out what happened on github I didn't even have to hit update Hanselman, that's me Shan Suleman merged the commits intoMaine, so Maggie is now an open source contributor.
If we assume my text file is open source, she made a pull request and then I can come down here and I can make a comment congratulating her for editing a text file and I can say cool, send it with the ship, squirrel, send it, good work, okay, so my pull request is now closed. I closed that pull request, so let's think about this. I had a local copy of get from my git repository. I connected it to the origin. to something that was origin or upstream, in this case they are the same and it was on github connected, both could have been done automatically, but I chose to do it manually, then my friend made a pull request, made a fork, made a copy, cloned it on his own machine he made a change he made a branch he put that change on the branch he told me about it he requested I stopped it and pulled it manually then I merged it just like we did at the end of number two I merged it into main and then I pushed it from my machine local to cloud and if we look at this now we can see Maggie's test and look at this, this text file has two contributors, you will see this when you work on a large project. with git you will have dozens of contributors, this means that everyone was involved which is great and is why open source is so fun, but again you will notice that Maggie's branch is not here because Maggie's branch ended up in the repository from Maggie and now that she's I heard I went and merged her pull request.
She might delete the branch because it was just a feature or something she was working on, so that's the dirty little secret about pull requests. It's a convention. It's an agreement. and how we communicate and we're using remotes and git branches to do that so I hope this was helpful and thank you Maggie for helping me with my video. This is step 2 of the obtaining tutorial that I didn't think I would follow. what to do if this is helpful please leave a comment tell your friends and I guess kids say smash that Bell please subscribe and maybe I can buy a taco with my YouTube main money that we make dozens dozens of dollars with What do we earn with YouTube, thanks friends

If you have any copyright issue, please Contact