WEBVTT 00:05.940 --> 00:13.800 In this video you're going to get introduced to more concepts in GitHub and that includes cloning forking 00:14.100 --> 00:16.170 and pull requests. 00:16.170 --> 00:21.420 So let's go through an example which covers these concepts in detail. 00:21.720 --> 00:29.970 So in the previous video we made changes to our local repository and then we pushed those changes to 00:30.150 --> 00:31.280 get hub. 00:32.010 --> 00:40.800 So by now you must be familiar with committing changes creating snapshots in your local repository and 00:40.800 --> 00:44.930 pushing any content to an online get Hub Repository. 00:44.940 --> 00:50.930 You can also make changes directly inside GitHub and make commits as well. 00:50.950 --> 00:58.130 Now let's suppose that a collaborator which does not have access to our github account. 00:58.160 --> 01:00.960 We would like to make a contribution to our projects. 01:00.990 --> 01:09.960 So for example they want to optimize our code or add a new feature or fix a bug and they would like 01:09.960 --> 01:15.610 to push those changes to our own github account. 01:15.630 --> 01:21.230 Well they don't have access to our github account so we need to find a solution. 01:21.660 --> 01:23.960 So what they can do. 01:24.360 --> 01:31.060 They can fork our own repository into their own github accounts. 01:31.670 --> 01:33.890 So what does it mean exactly. 01:33.890 --> 01:44.570 Well forking means that you create a copy of a get Hub Repository in your own get hub account. 01:44.630 --> 01:51.410 So basically you are creating a new repository in your own account which is an exact copy of another 01:51.890 --> 01:54.830 repository in GitHub. 01:54.980 --> 01:58.620 So let's go ahead and implement this step. 01:58.730 --> 02:06.980 So the left hand side you can see my own repository projects which is inside this account of your code 02:07.820 --> 02:12.290 and you can see all the files inside that repository. 02:12.290 --> 02:21.710 Now on the right hand side I opened a private tab and this github account belongs to somebody else which 02:21.710 --> 02:24.680 we're gonna call gentle collaborator. 02:24.830 --> 02:32.430 So this is the collaborator who is looking to add changes to our own projects. 02:32.720 --> 02:37.710 So other moments this collaborator doesn't have any repositories in their account. 02:38.950 --> 02:46.660 So they would like to fork our own repository so to do that first of all they need to find our repository 02:47.350 --> 02:50.950 so they can either use our repository link 02:54.010 --> 03:02.270 and access our repository otherwise they can look for the repository projects or the user of UK. 03:02.470 --> 03:05.300 So let's look for the user of code. 03:05.320 --> 03:06.150 It's gonna be easier. 03:07.440 --> 03:17.450 So we looking inside GitHub and now if you click on users that's our user. 03:17.560 --> 03:23.030 So if I click on it I can see all the repositories of that specific user. 03:23.080 --> 03:26.200 So this is the repository that I'm interested in. 03:26.200 --> 03:30.980 So now you can see all the files inside that repository. 03:31.030 --> 03:40.090 Now we want to fork this repository into this new github account so remember that we are currently inside 03:40.480 --> 03:48.880 gentle collaborators github accounts and over that that's our old github account of code. 03:48.880 --> 03:56.580 So to fork this repository insert into this new github account we need to click on the fork button. 03:56.650 --> 04:03.670 Now before doing that you may be looking on this green button right now which is clone or download. 04:03.670 --> 04:10.450 Well basically if you click there you're just gonna be downloading a copy of this repository to your 04:10.450 --> 04:14.920 own computer or your own local environments. 04:14.950 --> 04:20.830 So cloning is the same as downloading and it's something we're going to do in a bit as well. 04:21.040 --> 04:25.720 So for now let's fork this repository to this new github accounts 04:28.720 --> 04:34.540 and now you can see that's after the forking finished. 04:34.540 --> 04:42.850 We are now inside the repository projects which is inside the gentle collaborator accounts. 04:43.050 --> 04:51.590 And if you look in the old repository projects that was inside the off your code accounts. 04:51.730 --> 04:51.980 All right. 04:51.980 --> 05:02.400 So now we have decided this new repository to the new github account and now we can make changes inside 05:02.670 --> 05:09.690 this repository without affecting the original repository which is inside of your code because this 05:09.690 --> 05:18.340 one is inside another account now instead of making changes directly inside get hub we would prefer 05:18.610 --> 05:27.030 to make a copy of that repository into our own local repository in order for us to use our favorites. 05:27.040 --> 05:28.840 Ed for example. 05:28.840 --> 05:32.510 So we can do now is called cloning. 05:32.510 --> 05:44.730 So again cloning is making a copy of that gets Hub Repository into your own local environments so once 05:44.730 --> 05:52.320 we do that we aren't going to make some changes locally to this repository and then commit those changes. 05:52.410 --> 06:00.540 So to clone the repository I'm going to click on the clone button and then I'm going to use this link. 06:00.540 --> 06:03.520 So I'm going to do this inside my desktop. 06:03.600 --> 06:06.750 So let's go to the desktop 06:10.820 --> 06:17.300 now if I look inside my desktop I've got a folder called projects already. 06:17.300 --> 06:19.520 Now this will create a conflict. 06:19.550 --> 06:27.220 If I try to clone the repository right here because this will create a folder which is called Project 06:27.220 --> 06:27.820 as well. 06:27.980 --> 06:31.680 So I need to rename that new folder something else. 06:31.850 --> 06:41.870 So the command to use to clone is get clone followed by this link and I'm going to choose a new name 06:41.870 --> 06:52.840 for the folder and I'm going to call it cloned grep for clone repository. 06:52.860 --> 07:00.480 So now if I check my desktop I'm going to find a new folder there and if I open it I can see the contents 07:01.080 --> 07:03.360 of the repository. 07:03.360 --> 07:10.440 Now obviously you don't see files like the Gates ignored file because there are hidden files. 07:10.440 --> 07:13.650 Now you can open this project inside brackets 07:18.170 --> 07:19.160 and make changes 07:25.330 --> 07:37.420 so if for example I'm going to add one line to file five and also against one line to file six. 07:37.760 --> 07:43.630 Now I'm happy with these changes so I'm going to commit them and push them to get up. 07:44.430 --> 07:55.020 So first I'm gonna go inside the folder and then I'm going to use gates and or before doing that. 07:55.050 --> 07:58.200 Let's check the outputs of Gates log. 07:58.700 --> 08:08.010 And here you can see the across the whole history of this repository including any merges 08:10.840 --> 08:13.270 commits and so on. 08:13.270 --> 08:14.960 Everything is there. 08:15.110 --> 08:16.690 All right. 08:16.690 --> 08:23.500 So when you clone a repository you actually own the full contents of the repository including the gates 08:23.500 --> 08:27.640 files which include the gate log and so on. 08:27.640 --> 08:44.610 So let's stage our files and let's commit. 08:44.740 --> 08:51.040 All right now that we committed our changes let's push the changes to get up so to do this. 08:51.040 --> 08:58.600 First of all as we've done before we're gonna need to create a remote using get remote cut. 08:59.170 --> 09:09.790 So we gonna call the remote something else then origin uh I'm going to call its origin to or origin 09:09.930 --> 09:10.240 Claire 09:13.210 --> 09:21.000 and the link we need to use is the same as that's one now to push the repository to get hub. 09:21.020 --> 09:31.660 We're going to use Gates push and then minus you to remember the branch and then the name of our origin. 09:31.680 --> 09:38.240 We call these origin clearing and then the branch as we are pushing too. 09:38.340 --> 09:44.510 And that's going to be the master branch so again minus you is to remember this branch so that next 09:44.510 --> 09:52.760 time if you want to push to the same remote you can use Gates push the name of the remote and it will 09:52.760 --> 09:57.960 do that to the master branch for you because it's remember this. 09:58.160 --> 09:58.820 Let's try this 10:02.180 --> 10:04.210 so our push has been rejected. 10:04.700 --> 10:11.780 And that's because I'm already locked into a different get hub account which is of your code and I'm 10:11.780 --> 10:17.500 trying to push to this new github account. 10:17.540 --> 10:20.950 So this is something we're going to fix in the next video.