So now I'm going to demonstrate for working well, for working and cloning, because all that forking
does is it makes us a copy of a GitHub repo on our GitHub account.
Right.
It just makes a copy that we have access and permission to do whatever we want with, but that doesn't
mean we have it on our machine.
So the demonstration repo I'll be working with is this 2048 repo.
We actually cloned it a while ago when I first entered cloning.
It's for this very addictive 2048 game.
It's just a single HTML file, some JavaScript, some CSS.
Anyway, I can clone it right now just like any other repository.
But if I clone that and make changes and make my own commits, I can't push those up.
Right?
I don't have permission unless I ask to be a collaborator somehow.
That's not how this works.
That's not how GitHub works.
So instead, if I want to make my own changes and push them up to GitHub, maybe just to show other
people, let's just start there.
I want my own version on GitHub where I can totally screw things up and share it with people, maybe
even add my own collaborators.
I want to work with my friend who I don't have friends these days, my friend llama lady.
I want to work with her on our own version of 2048.
We'll use this as a starting point and then I will fork it or she can fork it and then I can add her
as a collaborator.
So I'm going to fork it to my personal account.
It takes a moment, but we should.
Well, you can already see Colt 2048.
My own copy.
I have all the files, I have all the history.
But now I could do things like add my own collaborators or change the access, protect a branch, delete
branches, whatever I want.
So now I can clone this down to my machine.
So I could clone the original too.
Right?
There's nothing stopping me.
It's a public repo.
But if I clone this one, when I clone it, the remote will be set up for me automatically so that I
can push up to here versus with a cloned version of the original.
If I clone this, I can't push up to origin because Origin will be Gabriel Ciruli.
That will be this account, right?
I can't push to this repo.
I can push to this one, so I'll copy that URL and then I'll clone it down to my machine.
So let's get out of here.
Get clone.
All right, so we have that new directory, 2048.
Get status.
Cool.
We see all the files and let's do get log.
I see the full history.
Lots and lots of commits.
But also if I do a git remote v you can see that origin is set to my own fork.
This is my repo on github, not the original.
So now I can do whatever I want.
I can diverge and make some serious changes.
So let's open this up.
So here it is in the browser, just the file indexed html.
I'll make some very simple changes.
A single commit.
Let's go with, I don't know, 2048.
Forked like that.
Not an exciting change.
Oh, God, that really screwed things up, huh?
Okay, well, let's go with 2048 and keep it like that.
Well, maybe we'll just change some styling then.
Very simple new background color.
Okay, well, I fast forwarded a bit.
I modified some of the CSS.
So now this is what the game looks like but didn't really do anything worthwhile.
But I can see the colors have changed a little bit compared to the original which looked something like
that.
They're not for the better necessarily, but I've changed some CSS so I can make those commits and do
whatever I want locally.
So this is my local git.
I can make a commit on the master branch, which is where I am by default.
Or I can go to some other branch.
Get switch.
I'll just commit directly to master I guess.
Get add dot get commit dash m change color palette.
Cool.
So I have that change locally, which I could do on any repo whether I cloned it or forked and cloned.
You have permission to make commits on your own local repo.
But what I don't have permission to do unless I own the repository or I've been granted collaborator
privileges is push as we already know.
So I own this repository because I forked it so I can push up and push that new change to my fork.
Get remote v.
So if I push my master branch to origin just like that, get push origin master.
Now my new commit is on my fork and we see change color palette, right?
All the other commits are like years and years ago and then 36 seconds to go.
So that's just on my fork.
It has nothing to do with the original project, aside from the fact that I made my own copy of the
original project and made changes to it.
But I'm not working on this original repository.
I'm working on my fork and I can do whatever I want.
I can add somebody else on here, we can collaborate.
We can destroy this without ever impacting the original, without needing permission.
That's the whole point of forking.
So in the next video, I want to talk about this workflow that stems from the ability to fork where
we can fork and then collaborate on an open source project or just as a team with a bunch of forks and
a centralized repository.