WEBVTT 00:06.470 --> 00:12.770 In this video you're going to apply what you learned in the previous video about Gates using the command 00:12.770 --> 00:13.640 line. 00:13.640 --> 00:16.620 So basically you're going to create a projects. 00:16.700 --> 00:24.050 Make some changes inside the projects and manage the versions of lots projects using gates. 00:24.080 --> 00:26.210 So let's go ahead and do this. 00:26.480 --> 00:38.410 So I'm gonna go to my desktop and I'm going to create a folder and call it Project. 00:38.420 --> 00:48.320 Now I'm going to go inside this folder and if I do this my folder is empty at the moment. 00:48.320 --> 00:51.170 Now let's open this folder using brackets 00:57.250 --> 01:06.690 so we need to go back to the desktop and then type brackets the name of the folder. 01:07.020 --> 01:11.110 So now here is our folder and it's empty at the moment. 01:11.710 --> 01:19.770 So first of all we need to initialize a Gates repository inside our folder. 01:19.770 --> 01:21.930 So we need to go inside the folder 01:25.520 --> 01:28.920 and then use the command gates in it. 01:28.940 --> 01:33.040 So this will initialize an empty Gates repository for us. 01:33.350 --> 01:38.570 And you will find a folder called Dr. Gates inside your repository. 01:38.570 --> 01:44.420 So if I try Ellis I don't see anything because that folder is hidden. 01:44.420 --> 01:49.430 So I need to use Ellis minus a to see the hidden contents. 01:49.430 --> 01:51.730 And here is our folder right there. 01:51.800 --> 01:57.050 Now if you want you can go to that folder and explore its contents 01:59.790 --> 02:10.080 and here are the different files that Gates will need to manage the different versions of your project. 02:10.080 --> 02:17.950 So now let's go back to our projects folder and it starts making some changes inside. 02:18.000 --> 02:24.840 So I'm going to create our first file and call it file one. 02:25.000 --> 02:27.260 Both text. 02:27.770 --> 02:29.390 So here is our file. 02:29.520 --> 02:33.900 Now without making any changes I'm going to make a comment. 02:34.280 --> 02:36.840 So first of all let's do Gates. 02:39.000 --> 02:43.760 And you can see that we've got one file that's is not tracked. 02:43.920 --> 02:49.580 So let's track this file by R. then it's to the staging area. 02:49.610 --> 02:56.730 So get odd the name of our file say if I try and get searches. 02:56.740 --> 03:04.370 Now they can then I can see one file there and it's a new file and that's the modification we've got 03:04.430 --> 03:05.210 at the moment. 03:05.210 --> 03:09.260 We are there's a new file so now if I commit 03:11.780 --> 03:20.290 so the syntax is get and then commits and then you use minus and aren't a message to your commit. 03:21.120 --> 03:27.470 So I'm gonna say created file one not text. 03:27.600 --> 03:28.710 All right. 03:28.710 --> 03:32.440 So now you can see the details of our commits. 03:32.460 --> 03:40.430 So one file changed and we have got a creation of that file. 03:40.560 --> 03:49.970 So now if you want you can check the history of your commits by using the command Gates log now you 03:49.970 --> 03:52.900 can see all the committee does you've done. 03:52.910 --> 03:57.210 So far we've got only one commits at the moments. 03:57.260 --> 03:59.900 This is the one so for each committee. 03:59.900 --> 04:05.180 You're going to have a harsh like France which identifies your commits. 04:05.210 --> 04:11.040 Now you can read their head arrow master. 04:11.150 --> 04:21.110 So this means that we are currently in the master branch of the projects and the head is normally referring 04:21.110 --> 04:23.480 to which branch we are working on. 04:23.500 --> 04:32.570 So at the moment we can say that Gates is pointing to the master branch or or the head is pointing to 04:32.570 --> 04:35.670 the master branch in our projects. 04:35.720 --> 04:38.870 Now you can create more branches if you like. 04:38.870 --> 04:44.060 That's something we gonna do later but for now just remember that we are inside one branch and that's 04:44.150 --> 04:45.350 our master branch. 04:45.350 --> 04:50.560 So the default branch is the master branch and that's where we are pointing. 04:50.570 --> 05:00.830 So now let's make a few changes to our file so I'm going to add line one line too and line three and 05:00.830 --> 05:02.430 then let's make another commits. 05:02.450 --> 05:09.390 So first of all we need to add our file to the staging area. 05:09.430 --> 05:13.710 So get out and I can use the name of the file. 05:13.720 --> 05:18.670 Now if you want to add everything inside your projects you can just use a dot like this. 05:18.670 --> 05:22.590 So this means does you want to stage everything inside the projects. 05:22.600 --> 05:31.750 So now if I try it gets get status then I can see that we've got one ratification of one file. 05:31.780 --> 05:33.130 Now let's commit 05:36.840 --> 05:47.970 and just say in the message that we have just modified file one the text or added three lines to file 05:47.970 --> 05:50.360 one not text. 05:50.400 --> 05:54.890 So here we go we've got three insertions inside our file. 05:55.020 --> 06:03.870 Now if you try get log then you will see that now we've got two commits and we are at the moment right 06:03.870 --> 06:07.720 there and that's our latest commit. 06:07.740 --> 06:09.270 All right. 06:09.270 --> 06:19.720 Now let's create another file file to dot text and make a change to file one dot text. 06:19.770 --> 06:22.270 So I'm going to change this line. 06:27.820 --> 06:32.610 So now let's have a look at some useful Gates commands. 06:32.620 --> 06:41.290 So let's say let's you would like to visualize the difference or the differences between the current 06:41.290 --> 06:48.120 state of file one the text and the estate of that file when it was last committed. 06:48.130 --> 06:55.570 So to do that you can use the command get diff followed by the path of your file. 06:56.500 --> 07:04.180 So in our case file one dot text and this will show you what's changed between the moments you committed 07:04.810 --> 07:08.620 that file and right now. 07:08.620 --> 07:18.250 So here we go so we can see that you replaced the contents of the third line with some new contents 07:19.230 --> 07:22.870 and that's exactly what's happened in our file. 07:22.900 --> 07:27.150 Now let's say that you made these changes and you're not happy with them at all. 07:27.280 --> 07:33.970 And you'd like to revert to the old states when you're last committed and you want to do this only for 07:33.970 --> 07:35.640 file one not text. 07:35.650 --> 07:42.990 So the command you can use here is called Get checkouts followed by the path of your file. 07:43.030 --> 07:45.940 So we are interested in file one the text only. 07:46.180 --> 07:51.490 So what's going to happen now is that we're going to revert to the old state of file one or texts when 07:51.490 --> 07:52.630 it was last committed. 07:52.960 --> 07:54.590 So let's try this. 07:54.770 --> 07:55.900 And here we go. 07:55.900 --> 07:59.760 That's how our file looked like when we last committed. 07:59.770 --> 08:04.230 So we brought our contents back. 08:04.230 --> 08:14.220 Now what if I make those changes but I'm not happy with for example and let's make a change to file 08:14.220 --> 08:20.590 too as well and let's say that we committed these changes. 08:20.640 --> 08:27.060 So at this stage our files and let's commit with a message 08:29.740 --> 08:44.920 created file to the text and changed line 3 in file one dot text so if we go to our history then we 08:44.920 --> 08:51.130 can see our new commits there and we're not happy at all with these changes. 08:51.130 --> 08:59.020 So if we try Gates checkouts applied to that file then it's not going to help because it's will take 08:59.020 --> 09:03.430 us to this state when we last commit it. 09:03.530 --> 09:06.800 And that's exactly that's. 09:07.080 --> 09:14.550 So we need to find an alternative because we want a different version of our projects for example that's 09:14.550 --> 09:17.300 one or that one to do that. 09:17.340 --> 09:20.060 We need to revert to an old commits. 09:20.160 --> 09:25.330 So let's have a look at this example and understand how this works. 09:25.470 --> 09:26.250 So let's say. 09:26.280 --> 09:30.850 But we've got our guest repository and we work in in the master branch. 09:30.850 --> 09:39.660 This is our case and it's say that we're making commits after changes so we've got for example four 09:39.670 --> 09:43.060 comets and this is our working environment. 09:43.060 --> 09:51.640 Now what we're going to do we are at this stage and we are not happy with the contents of one of our 09:51.640 --> 09:52.920 files. 09:53.050 --> 09:58.410 So we want to revert to one of these comets. 09:58.690 --> 10:11.270 So let's say that we want to revert to that snapshots number three so other moments we used that comets 10:11.300 --> 10:23.140 and we made some further changes so if I go back to our projects let's say thus I with another line. 10:23.410 --> 10:28.610 Line four and then realized that I'm not happy with that content. 10:29.080 --> 10:40.010 And I would like to revert to an old comet so the current state of the projects is the comet state plus 10:40.010 --> 10:46.400 some other changes in our case we added a new line to file one but text right. 10:46.700 --> 10:53.270 So other moments this is the comet where our head is pointing. 10:53.300 --> 10:56.440 So what we want to do we want to use an old Comet. 10:56.450 --> 10:58.540 So let's say comet number three. 10:58.550 --> 11:06.920 So we're going to move the head to that's comet like that and then we are going to change the contents 11:06.920 --> 11:19.320 of our gates or our working environment to the contents of that old comets like this. 11:19.330 --> 11:26.290 So now the content of our working environments matches the content of that old Comet. 11:26.860 --> 11:28.680 So this is the first step. 11:28.720 --> 11:31.120 So let's go ahead and do this. 11:31.210 --> 11:36.860 So the command we need to use here is called get reset. 11:37.020 --> 11:37.190 Right. 11:37.260 --> 11:38.380 Like this. 11:38.380 --> 11:41.720 And then we're going to use an option called hard. 11:41.800 --> 11:48.370 So when you use the option hard this means does your working environment is going to be reset towards 11:48.370 --> 11:49.270 ever state. 11:49.270 --> 11:50.560 You're going to specify here. 11:51.340 --> 11:55.490 So to specify which comets you want to revert to. 11:55.540 --> 11:58.210 You need to use the hash of that comet. 11:58.210 --> 12:05.850 So for example in our case let's say thus we want to go back to that comet so I'm going to use that 12:05.880 --> 12:09.020 hunched like this. 12:09.110 --> 12:14.750 So let's keep a close look at the contents of our files. 12:14.780 --> 12:16.370 So here we go 12:19.860 --> 12:22.420 missed one hyphen before hard. 12:22.500 --> 12:30.050 So let's try this again. 12:30.070 --> 12:30.460 Here we go. 12:31.180 --> 12:38.270 So now we can see that the contents of our file has now changed to the estates of those comets. 12:38.320 --> 12:42.760 And if we remember we didn't have a file two dots not text on that stage. 12:42.760 --> 12:49.080 So we changed the whole working environment to the estate of that comet. 12:49.090 --> 13:02.020 So now if you check the history of your comets get log you'll see that's we are at the moments pointing 13:02.200 --> 13:02.510 to. 13:02.530 --> 13:05.660 That's comets which we have just reverted to. 13:05.860 --> 13:06.820 And we need to be careful. 13:06.820 --> 13:14.380 We just reverted the contents of our working environment to the state of that comet but we still have 13:14.380 --> 13:16.690 the whole history of our comets. 13:16.690 --> 13:18.730 We didn't add a new comet. 13:18.730 --> 13:19.810 It's our project. 13:19.900 --> 13:26.910 We have just pointed the head to that comets at the moment. 13:26.950 --> 13:28.280 Now we've got a problem. 13:28.300 --> 13:36.730 We are pointing the head to this old comets but we would like to point the head to our latest comets. 13:36.730 --> 13:42.250 But keep the contents of the old comets just like this. 13:42.250 --> 13:44.620 So how can we do this. 13:44.650 --> 13:53.280 Well we need to use the command gets reset again but this time instead of hard we're going to use the 13:53.280 --> 14:01.960 option soft so soft will make it possible to move the head to another commits which is the latest commit 14:02.260 --> 14:05.410 without changing the content of our working environments. 14:05.650 --> 14:08.680 So this content will stay the same. 14:08.680 --> 14:17.480 So now we need to specify that we want to move to the previous comment and to do this. 14:17.570 --> 14:30.600 We're going to specify head at one and this will take us to the latest commit without changing this 14:30.600 --> 14:31.490 content. 14:31.590 --> 14:33.810 So let's go ahead and do this. 14:33.810 --> 14:34.200 Here we go. 14:34.920 --> 14:47.690 So now if I try get log again I can see that I'm pointing now to the latest commits whereas I was pointing 14:47.690 --> 14:53.020 to that commit when he tried get log before running the command. 14:53.120 --> 14:53.360 All right. 14:53.380 --> 15:01.170 So now we are pointing to the rights commits and we are ready to commit our changes. 15:01.220 --> 15:04.970 So let's go ahead and do this so gets 15:08.400 --> 15:25.170 to stage all files and gets commits with a message reverted to commits using this hash. 15:25.180 --> 15:30.430 So now if we check get log we can see now for commits. 15:30.440 --> 15:36.700 And the last commits is the one when we reverted to that commits. 15:36.700 --> 15:41.560 So the advantage of using this method is that we kept all our previous commits. 15:41.650 --> 15:43.540 We didn't destroy anything. 15:43.880 --> 15:53.500 So if you change your mind later on about this commits which you reverted to the old commits then you 15:53.500 --> 15:57.440 can always revert to that commits using the same method. 15:57.580 --> 16:02.160 And that's why this method is really safe. 16:02.170 --> 16:05.820 Now if you want you can carry on your changes in your working environment. 16:05.820 --> 16:08.590 So for example you can delete that line. 16:08.590 --> 16:19.370 You can create another file file three board text and one line to it and so on and you can seed your 16:19.370 --> 16:24.110 files again and make a new commits 16:31.190 --> 16:31.520 Here we go. 16:32.500 --> 16:45.540 So now if I check get log we've got another commits and now we have got five commits in total here we 16:45.640 --> 16:52.130 go to great start so I'm just gonna right on cue and here we go 16:55.810 --> 17:01.720 all right in the next video you're going to get introduced to the concept of branching in gets.