- Hello, welcome part three of my GitHub for Poets tutorial.
Serious, if anything this might be the most
important one for you to watch, or the most exciting
or perhaps, hopefully, maybe, if I can make it so,
the most interesting one to watch.
So what I have here is a poem.
It is in a GitHub repository.
I created an account called RainbowCoder,
and what I'm going to show you in this video
is how you, as someone who is not me,
could contribute to my repository.
Now this usually happens in the case of source code
'cause you want to fix a bug or suggest a change
but we're going to sort of not look at source code
to make things a little simpler,
so you might think of another line
you want to add to this poem, that sort of thing.
So how do you do that?
So there's two concepts first that I want to add
to our list of git concepts before I start
typing stuff in here in the browser.
I'm going to come over here.
These are all the concepts I've covered so far
in the previous two videos and I'm going
to add two things to our list here.
I'm going to add fork,
and I'm going to add pull request.
So these are the two new concepts
that I'm covering in this video.
Now, what does it mean to fork a repository?
So let's say this little circle here
with the word repo in it represents a particular repository.
And you've been making changes along that repository,
add a diagram like this, a bunch of different commits
and then also perhaps you had some branches
where you tried some other things out
and you merged those branches in, that sort of thing.
This repository is sitting
on GitHub in my account,
Rainbow Coder.
What if you love this repository so much
you want to take an entire duplicate instance of it
and have it live in your account
so you can work on it separately with the same stuff
but not be monkeying around with mine,
not have to have privileges or permissions to make changes
here but also by accident not mess something up,
if you weren't sure about what you were doing just yet.
This is what it means to fork a repository.
Forking a repository is essentially like...
I was almost going to use the word clone
but I don't want to use the word clone
because that's a specific GitHub term that I'm going to
add to this list for later, but it's like taking
an entire other instance of the repo
and just having it under your account.
So I have another GitHub account which is my name one
called shiffman, and what I'm going to do is
I'm going to pretend to be both Rainbow Coder and Shiffman.
I guess I don't have to pretend to be Shiffman
because that who I am, maybe.
Anyway, this is all getting a little bit strange.
So I'm going to fork it and then I will have in my account,
my GitHub account, an exact replica,
I'm going to get this right, of this entire repository
and its whole history.
So that if I decide to do some stuff,
I can make as many branches and do various things
that I want without affecting the original core version.
That's forking.
Now, that's what it means to fork.
Now, what does pull request mean?
Pull request means, let's say that this particular branch
that I've been working on, I just love it.
I have come up, with the most elegant, poignant,
meaningful, set of verse... ever,
and I want to
contribute it back to the original repository.
That would be a pull request, now, what am I doing?
I'm essentially sending this code to this repository
as a pull request, and it's up to RainbowCoder, to accept
or reject that pull request.
The reason why it's called a pull request in GitHub,
this is so extreme, but let's say I want to send something
this direction, that's going to be a push.
If I want to get something the other direction, pull,
that's going to be a pull.
So, sending out is pushing, ah, coming in is pulling.
So, really, I as Shiffman, want to push my stuff over here,
but I can't because I don't have permission here,
so I'm saying, would you please, RainbowCoder, pull
my changes, that's a pull request, okay?
So these are the concepts, lets go and actually do it here,
and if you are watching this live, or if you're watching
the archive version of this video, please make
a pull request, we're going to invent the world's greatest
collaborative poem about rainbows and since today
is Earth Day, I don't know what it will be when
you are watching this, but maybe add some stuff about
the earth in there too.
Okay, back over here, now, here it is.
So, I am logged in here, as RainbowCoder, and what I've done
already, in a separate browser window,
is I am at this exact
URL of this particular repository, but I am logged in,
as Shiffman, and you can see here, my little smiling icon
is up there, and I'm looking at the RainbowCoder's account
and the Rainbow Poem repository.
So, the truth of the matter is, all of this stuff, I could
fork and then make a pull request, and do all that,
but there's actually a really quick and simple way
to do this, because GitHub will kind of take care
of everything for you, and I'm going to show you that first.
Because, you could say we can go to the poem, and like,
look, there's the edit button and look what it says,
fork this project and edit the file.
So, GitHub already knows that you don't have permission
to edit the file directly, so it assumes if you're trying
to edit it, that you're going to fork, you want to fork
the entire project.
So if I actually just click edit, it's going to automatically
create that fork for me.
Another way I could create the fork, is to click this button
up here, you can't really see that, this button up here
in the top right corner, fork.
So I don't know which one I really want to do right now,
flip a coin, spin a wheel, let's start with the, let's do,
let's fork it, let's do the fork.
C'mon, let's be, let's be, bold, today, okay.
So I'm going to click this fork button right now, here it goes.
Oh, look at this, so one thing you'll notice, by the way,
that I, as a GitHub user belong to a bunch of different
organizations, and the organizations have different
accounts, interesting to note this, you, if you just signed
up, probably won't have this happen to you,
but I'm going to fork it to my Shiffman account.
You can see it's forking, it.
It should only take a few seconds, c'mon GitHub do the fork
dance.
Okay, it finished, so I don't have to dance anymore.
So now you can see, look at this.
I now, have an entire duplicate version of this repository
under my account, and it even says where I forked it from.
This all makes sense, right?
So now what I want to do is go back to poem, and you can see
I am working in it, and I can just hit edit now.
So I can edit this, and let's, um, Earth,
by the way, everybody, when you're doing your forks and pull
requests, please correct, get rid of my original poem.
Nothing about it was any good.
Earth day is a day, oh, wait, okay, oh let's just say
I dunno, recycle, hahaha, recycle is okay, I panicked,
I didn't know what to put about earth day.
So I'm adding a line, recycle, and then I'm going to now,
go down here, and look at this.
So, I can commit directly to the master branch.
Now, note, because I'm working in a fork, I'm committing
to this master branch, in my forked version of the repo,
not the RainbowCoder one.
But sometimes it's kind of good practice, if I'm ultimately
going to propose a change to somebody else with a pull request,
to maybe create a new branch.
So let's do that and let's call this branch
shiffman recycle, and I'm going to say, adding recycle.
Recycle!
I'm doing a terrible disservice to the world, by not putting
in excellent thoughtful commit comments, but you should
be a lot more thoughtful about that.
And then I'm just going to do propose file change.
Now, interestingly enough, oh whoah!
This is so, um, aaahhhhh, tst tst tst tst
I did this in an overly complicated way by making
a separate branch, but it's fine, because, what I'm doing
here is, what it wants me to do, is automatically,
it's fine, I got to restart this video, it's fine,
let's keep going, this is so crazy, but it's fine,
this is normal and we should run into these types of things,
and figure them out.
So, because I created a separate branch, GitHub
is sort of, automatically detecting that maybe I want to
propose to merge it back in here.
And you know, from there I might do a pull request.
Let's actually, let me go backwards, and I'm not going to
do this extra step of the extra branch, I'm just going to
edit master directly and then do a pull request from there,
which might be a little bit simpler and somebody
on the internet is probably going to yell at me, that I'm doing
things incorrectly, and then I'll make another video
to correct them.
Okay, so, what I'm actually going to do, even though I said
something different, is click merge pull request,
and confirm merge, and so now you can see, my particular,
oops, my particular version of the repository.
I was doing so well,
now has the recycle in it.
So, what I just did there was an extra step of making
an extra branch, was rather unnecessary, because
I could've just edited master directly, because I'm only
working within my version of the repository.
Let me get to the important point now, hopefully I didn't
waste too much of your time.
What happens now, if I,
go to here.
Now look at this.
I, there is an option right here now, I'm in Shiffman's
rainbow poem.
I can say new pull request, and what that's going to do,
is say to the, when I click new pull requests, it's going to
tell the original repository, RainbowCoder, that I have now
a pull request.
I'm going to create a pull request, with this commit, adding
recycle, I'm going to create that pull request.
I'm going to say, hey, I added recycle, please, this, I am
really thinking about the earth and how much I love
rainbows, today.
So I'm going to create this pull request, and now, there's
nothing left for me to do, I just sit and wait.
I wait with baited breathe, and anticipation, hoping
that my pull requests gets accepted, and yet, even if your
pull request doesn't get accepted, you have done a good
thing on the internet today, by learning about
and submitting a pull request, not all pull requests get
accepted, but just the act of doing one, is a positive
thing to do in the world.
So, now I can go to the window, I can go back now,
as the RainbowCoder, I can go back to this original
repository, and I can click, I can select now.
This is if somebody, now pretend you're, somebody gives
you a pull request, I can go here, to pull requests,
and I can see, does somebody actually added another pull
request here, already, I'm going to merge that one in perhaps
a little bit later.
I'm going to look at this one, I can see, like, ah ha,
what was changed, this is the thing that was changed.
I can look at it and say, blue, green , indigo, recycle,
unicorn, yellow, you know, maybe I would have put recycle
after unicorn, but, pretty good.
So, I'm going to, because this video now has gotten
way too long, I'm going to go back to here, and at first I'm
going to write, thank you so much, I love this change,
and I'm going to hit commit, and I'm going to do it, I'm going to
do merge pull request, and we have now started, even though
it's just me doing the pull requests, the first, the worlds
first, this might not be true, but the worlds first
collaborative GitHub poem about rainbows on poem in your
pocket day, or the day after poem in your pocket day.
Okay, so this is the end of part three.
I encourage you, to go online, try to make a pull request
to my repository, the link to the repository will
be in the videos description.
Find another repository, if you know about code, fix
somebody's bug, in somebody else's repository,
add something, go and make a pull request on the internet
on GitHub today and see how that goes, and in part four,
I'm going to do something more with GitHub, look for part four,
I forgot what it is, but I'm going to keep going
with this stuff.
Okay, see ya soon, goodbye.