1 00:00:00,090 --> 00:00:05,430 So now I'm going to demonstrate for working well, for working and cloning, because all that forking 2 00:00:05,430 --> 00:00:09,750 does is it makes us a copy of a GitHub repo on our GitHub account. 3 00:00:09,750 --> 00:00:10,010 Right. 4 00:00:10,020 --> 00:00:15,600 It just makes a copy that we have access and permission to do whatever we want with, but that doesn't 5 00:00:15,600 --> 00:00:17,250 mean we have it on our machine. 6 00:00:17,430 --> 00:00:22,170 So the demonstration repo I'll be working with is this 2048 repo. 7 00:00:22,170 --> 00:00:25,830 We actually cloned it a while ago when I first entered cloning. 8 00:00:25,830 --> 00:00:28,680 It's for this very addictive 2048 game. 9 00:00:28,680 --> 00:00:32,460 It's just a single HTML file, some JavaScript, some CSS. 10 00:00:32,460 --> 00:00:36,660 Anyway, I can clone it right now just like any other repository. 11 00:00:36,660 --> 00:00:42,450 But if I clone that and make changes and make my own commits, I can't push those up. 12 00:00:42,450 --> 00:00:43,020 Right? 13 00:00:43,020 --> 00:00:46,410 I don't have permission unless I ask to be a collaborator somehow. 14 00:00:46,440 --> 00:00:47,880 That's not how this works. 15 00:00:48,420 --> 00:00:49,710 That's not how GitHub works. 16 00:00:49,710 --> 00:00:55,140 So instead, if I want to make my own changes and push them up to GitHub, maybe just to show other 17 00:00:55,140 --> 00:00:56,610 people, let's just start there. 18 00:00:56,610 --> 00:01:02,580 I want my own version on GitHub where I can totally screw things up and share it with people, maybe 19 00:01:02,580 --> 00:01:04,349 even add my own collaborators. 20 00:01:04,349 --> 00:01:11,370 I want to work with my friend who I don't have friends these days, my friend llama lady. 21 00:01:11,370 --> 00:01:14,820 I want to work with her on our own version of 2048. 22 00:01:14,820 --> 00:01:20,550 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 23 00:01:20,550 --> 00:01:21,630 as a collaborator. 24 00:01:21,630 --> 00:01:23,970 So I'm going to fork it to my personal account. 25 00:01:25,440 --> 00:01:27,700 It takes a moment, but we should. 26 00:01:27,730 --> 00:01:30,480 Well, you can already see Colt 2048. 27 00:01:30,570 --> 00:01:31,770 My own copy. 28 00:01:31,770 --> 00:01:34,770 I have all the files, I have all the history. 29 00:01:35,100 --> 00:01:42,060 But now I could do things like add my own collaborators or change the access, protect a branch, delete 30 00:01:42,060 --> 00:01:43,910 branches, whatever I want. 31 00:01:43,920 --> 00:01:46,920 So now I can clone this down to my machine. 32 00:01:47,130 --> 00:01:49,110 So I could clone the original too. 33 00:01:49,200 --> 00:01:49,620 Right? 34 00:01:49,620 --> 00:01:50,520 There's nothing stopping me. 35 00:01:50,520 --> 00:01:51,570 It's a public repo. 36 00:01:51,570 --> 00:01:58,020 But if I clone this one, when I clone it, the remote will be set up for me automatically so that I 37 00:01:58,020 --> 00:02:02,730 can push up to here versus with a cloned version of the original. 38 00:02:02,910 --> 00:02:09,330 If I clone this, I can't push up to origin because Origin will be Gabriel Ciruli. 39 00:02:09,840 --> 00:02:11,490 That will be this account, right? 40 00:02:11,490 --> 00:02:13,200 I can't push to this repo. 41 00:02:13,230 --> 00:02:18,660 I can push to this one, so I'll copy that URL and then I'll clone it down to my machine. 42 00:02:18,840 --> 00:02:20,190 So let's get out of here. 43 00:02:21,720 --> 00:02:23,040 Get clone. 44 00:02:25,830 --> 00:02:30,150 All right, so we have that new directory, 2048. 45 00:02:31,130 --> 00:02:32,240 Get status. 46 00:02:32,750 --> 00:02:33,270 Cool. 47 00:02:33,290 --> 00:02:36,290 We see all the files and let's do get log. 48 00:02:36,290 --> 00:02:37,880 I see the full history. 49 00:02:38,420 --> 00:02:40,610 Lots and lots of commits. 50 00:02:40,610 --> 00:02:48,470 But also if I do a git remote v you can see that origin is set to my own fork. 51 00:02:48,500 --> 00:02:51,830 This is my repo on github, not the original. 52 00:02:51,980 --> 00:02:53,360 So now I can do whatever I want. 53 00:02:53,360 --> 00:02:55,670 I can diverge and make some serious changes. 54 00:02:55,670 --> 00:02:56,990 So let's open this up. 55 00:02:56,990 --> 00:03:01,490 So here it is in the browser, just the file indexed html. 56 00:03:01,880 --> 00:03:03,410 I'll make some very simple changes. 57 00:03:03,410 --> 00:03:04,520 A single commit. 58 00:03:04,880 --> 00:03:08,360 Let's go with, I don't know, 2048. 59 00:03:09,140 --> 00:03:11,870 Forked like that. 60 00:03:12,080 --> 00:03:13,730 Not an exciting change. 61 00:03:14,120 --> 00:03:16,130 Oh, God, that really screwed things up, huh? 62 00:03:16,450 --> 00:03:19,500 Okay, well, let's go with 2048 and keep it like that. 63 00:03:19,520 --> 00:03:21,980 Well, maybe we'll just change some styling then. 64 00:03:21,980 --> 00:03:24,530 Very simple new background color. 65 00:03:24,590 --> 00:03:26,690 Okay, well, I fast forwarded a bit. 66 00:03:26,690 --> 00:03:28,510 I modified some of the CSS. 67 00:03:28,520 --> 00:03:33,110 So now this is what the game looks like but didn't really do anything worthwhile. 68 00:03:33,110 --> 00:03:39,260 But I can see the colors have changed a little bit compared to the original which looked something like 69 00:03:39,260 --> 00:03:39,770 that. 70 00:03:39,770 --> 00:03:47,060 They're not for the better necessarily, but I've changed some CSS so I can make those commits and do 71 00:03:47,060 --> 00:03:48,410 whatever I want locally. 72 00:03:48,590 --> 00:03:50,720 So this is my local git. 73 00:03:50,960 --> 00:03:54,830 I can make a commit on the master branch, which is where I am by default. 74 00:03:54,830 --> 00:03:56,690 Or I can go to some other branch. 75 00:03:56,720 --> 00:03:57,710 Get switch. 76 00:03:58,580 --> 00:04:00,350 I'll just commit directly to master I guess. 77 00:04:00,380 --> 00:04:07,160 Get add dot get commit dash m change color palette. 78 00:04:08,180 --> 00:04:08,860 Cool. 79 00:04:08,870 --> 00:04:13,820 So I have that change locally, which I could do on any repo whether I cloned it or forked and cloned. 80 00:04:14,090 --> 00:04:17,110 You have permission to make commits on your own local repo. 81 00:04:17,120 --> 00:04:22,130 But what I don't have permission to do unless I own the repository or I've been granted collaborator 82 00:04:22,490 --> 00:04:25,160 privileges is push as we already know. 83 00:04:25,550 --> 00:04:33,140 So I own this repository because I forked it so I can push up and push that new change to my fork. 84 00:04:33,770 --> 00:04:35,100 Get remote v. 85 00:04:35,660 --> 00:04:41,180 So if I push my master branch to origin just like that, get push origin master. 86 00:04:41,210 --> 00:04:46,740 Now my new commit is on my fork and we see change color palette, right? 87 00:04:46,760 --> 00:04:50,900 All the other commits are like years and years ago and then 36 seconds to go. 88 00:04:51,200 --> 00:04:53,230 So that's just on my fork. 89 00:04:53,240 --> 00:04:59,060 It has nothing to do with the original project, aside from the fact that I made my own copy of the 90 00:04:59,060 --> 00:05:00,920 original project and made changes to it. 91 00:05:00,920 --> 00:05:03,890 But I'm not working on this original repository. 92 00:05:03,890 --> 00:05:06,500 I'm working on my fork and I can do whatever I want. 93 00:05:06,500 --> 00:05:08,630 I can add somebody else on here, we can collaborate. 94 00:05:08,630 --> 00:05:13,300 We can destroy this without ever impacting the original, without needing permission. 95 00:05:13,310 --> 00:05:15,050 That's the whole point of forking. 96 00:05:15,260 --> 00:05:21,230 So in the next video, I want to talk about this workflow that stems from the ability to fork where 97 00:05:21,230 --> 00:05:27,800 we can fork and then collaborate on an open source project or just as a team with a bunch of forks and 98 00:05:27,800 --> 00:05:29,180 a centralized repository.