WEBVTT 00:05.630 --> 00:11.390 In this video you're going to get introduced to the concept of branching inversion control. 00:11.390 --> 00:18.010 So what is branching so far we have been working in one single branch. 00:18.110 --> 00:21.710 And that's the default branch which is the master branch. 00:21.800 --> 00:28.190 So all our changes our commits everything was happening in this branch. 00:28.240 --> 00:36.500 Now let's suppose that's in your projects you are developing a new feature and you want the developments 00:36.530 --> 00:42.710 of the core product to continue while you are developing the feature on the site. 00:42.830 --> 00:50.880 So to do this you can create one extra branch where you're going to do some developments which is going 00:50.880 --> 00:54.740 to be outside the master branch. 00:54.950 --> 00:58.150 So let's call this branch new feature. 00:58.370 --> 01:04.370 So the two branches are going to be completely separate but when you create this branch for the first 01:04.370 --> 01:12.230 time you're going to import all the contents from your master branches commits. 01:12.240 --> 01:20.010 So now we've got the snapshots just from there and we are ready to make our changes without affecting 01:20.220 --> 01:21.720 the master branch. 01:21.720 --> 01:29.070 So if you've got a team of developers you can allocate resources which will work on this branch only 01:29.400 --> 01:33.760 so they will be able to make updates commits and so on. 01:33.840 --> 01:43.980 Only on this branch and at the same time you'll be making changes and commits in the master branch. 01:44.060 --> 01:52.410 Now a quick comment about the first commits in the new feature branch in this branch you will still 01:52.500 --> 01:58.860 be able to access the past commits which you imported from the master branch. 01:59.220 --> 02:06.090 So when you import that snapshots you also import all the past commits which belong to the master branch 02:06.150 --> 02:09.170 so you can revert to any of those if you like. 02:09.180 --> 02:09.440 All right. 02:09.450 --> 02:17.110 So at this stage let's suppose that you are happy with the contents of the new feature branch and you'd 02:17.130 --> 02:19.490 like to incorporate it in the master branch. 02:19.920 --> 02:23.920 So here comes a new concept which is called merging. 02:24.060 --> 02:31.380 So you'll be able at this stage to merge the contents of the new feature branch with the contents of 02:31.380 --> 02:39.540 the master branch and the consequence is going to be a brand new snapshot which includes both your code 02:40.350 --> 02:44.120 from the master branch and your code from the new feature branch. 02:44.370 --> 02:51.840 And now you can continue your work making changes and commits as normal and you can also delete this 02:51.870 --> 02:54.880 new branch if you don't need it anymore. 02:54.900 --> 03:01.320 Now let's go back to our projects folder and apply the concept of branching and merging using the command 03:01.320 --> 03:01.850 line. 03:01.980 --> 03:08.430 So let's check the list of branches does we have got available at the moment using the gates branch 03:09.330 --> 03:10.200 command. 03:10.260 --> 03:14.160 So we've of course only one branch and that's the default branch. 03:14.160 --> 03:20.730 It's in green meaning it's the active one and also it's got an esoteric stair meaning about this is 03:20.880 --> 03:22.110 the current branch. 03:22.440 --> 03:28.360 So now let's create a new branch using get branch followed by the name of the branch. 03:28.380 --> 03:32.090 So let's call it new feature. 03:32.280 --> 03:34.830 So now if we try get branch. 03:34.860 --> 03:40.350 You can see two branches that's the oxy one and this one is the new one. 03:40.350 --> 03:42.870 So let's switch to that branch. 03:43.080 --> 03:48.920 So the command to use is get check out followed by the name of the branch. 03:48.930 --> 03:50.010 You would like to switch to. 03:51.300 --> 03:57.090 So if we try to get branch now you can see that the actually one is new feature. 03:57.180 --> 03:57.770 All right. 03:57.870 --> 04:03.040 Now let's make some changes to our projects and commit them inside this branch. 04:03.300 --> 04:12.990 So I'm going to create a new file file for both texts and let's add one line inside this file and let's 04:12.990 --> 04:15.360 also add one line inside. 04:15.360 --> 04:18.440 File three. 04:18.500 --> 04:35.230 So now let's stage all files and let's commit our changes. 04:35.300 --> 04:42.090 Now if you check get log you can see the history of commits in both branches. 04:42.190 --> 04:44.190 So they had other moments. 04:44.230 --> 04:49.980 He's pointing to the new feature branch and we've got one commits. 04:50.320 --> 04:53.060 And these are the changes that we have just made. 04:53.380 --> 04:56.950 And the other commits belong to the master branch. 04:57.080 --> 05:01.850 And if you want you can use the down arrow to check all commits. 05:02.020 --> 05:04.700 So go on Q2 to grits. 05:04.820 --> 05:13.950 And now if you switch to the master branch using Gates check out followed by the name of the branch 05:15.180 --> 05:22.000 you'll see that's now you will get the contents of the master branch. 05:22.480 --> 05:24.070 So let's have a look. 05:24.250 --> 05:24.850 And here we go. 05:25.290 --> 05:27.460 So that's the contents of the master branch. 05:27.580 --> 05:38.510 If you switch to the new feature branch then you'll see in your working environments the contents corresponding 05:38.510 --> 05:40.560 to that ranch. 05:40.580 --> 05:43.820 Now let's make one more change inside our new branch. 05:43.820 --> 05:47.940 So I'm going to create a new file and call quality file five dots. 05:47.960 --> 05:48.440 Text 05:51.510 --> 05:53.060 I'm going to add one line there. 05:54.270 --> 06:12.800 And I'm going to commit the changes after she staging all the files. 06:13.030 --> 06:19.210 All right now let's suppose that you are happy with the changes which you made inside the new branch 06:19.420 --> 06:22.690 and you want to merge them into the master branch. 06:22.870 --> 06:27.160 So to do that first let's switch to the master branch using gates. 06:27.170 --> 06:35.670 Check out so now you are inside the master branch. 06:35.670 --> 06:39.030 You can check that by using Gates branch. 06:39.030 --> 06:41.040 So this is the active branch. 06:41.040 --> 06:48.030 And now to merge the changes that you made inside the new branch you use Gates 06:52.980 --> 07:01.590 merge followed by the name of the branch so this will merge the contents of the new branch with the 07:01.590 --> 07:03.290 contents of the master branch. 07:08.510 --> 07:09.920 Let's try again with the correct 07:13.810 --> 07:14.140 name. 07:14.540 --> 07:15.520 Okay. 07:15.880 --> 07:20.160 So you can see here the changes which took place for each of these files. 07:20.170 --> 07:29.560 Now if you try get log you can see that Gates is pointing at the moment to the master branch which has 07:29.560 --> 07:36.520 been merged with the new feature branch and in the history of comets You can also see the commits made 07:36.760 --> 07:48.780 inside the new feature branch so now if you are happy with everything and you have merged the two branches 07:49.020 --> 07:51.500 you are ready to delete the new branch. 07:51.630 --> 07:59.160 So all you need to do is use Gates branch hyphen D followed by the name of the branch 08:01.840 --> 08:09.330 now we are able to use this command because we merged the new branch inside or with the master branch. 08:09.460 --> 08:16.990 If you haven't merged a branch and you still want to do it then you need to use copies of the inset 08:17.530 --> 08:19.230 because this one wouldn't work. 08:19.450 --> 08:28.080 So let's try this so our branch has been deleted and I if I check get branch I've got only one branch 08:28.440 --> 08:36.500 and if I check get log I can see that Gates is pointing to the master branch and you can also see the 08:36.560 --> 08:42.110 pass commits which took place inside the new feature branch before is course deleted. 08:42.260 --> 08:48.740 Hopefully this gave you a good understanding of the concepts of branching and merging in version control. 08:48.740 --> 08:52.790 Now before we move to the next video I'd like to introduce you to get. 08:52.790 --> 08:58.060 Ignore Gates ignore is simply a file which is called Gates ignore. 08:58.880 --> 09:06.590 Which you can place inside your project and inside this file you can add parts of files which you don't 09:06.590 --> 09:07.600 want to track. 09:07.610 --> 09:15.410 So for instance let's say that we've got a file called Keys North text which contains some sensitive 09:15.410 --> 09:19.220 information about your app with some API keys. 09:19.220 --> 09:27.660 For example let's say that it's got an API key which looks like this all right. 09:27.750 --> 09:29.900 And you don't want to track this. 09:29.910 --> 09:33.550 And also you don't want to share this key. 09:33.630 --> 09:38.140 If you push your project to a public repository later on. 09:38.820 --> 09:44.360 So all you need to do is add the path of your file to get ignored. 09:44.690 --> 09:49.420 So let's add a comment like this saying 09:54.440 --> 10:01.570 do not share keys and let's add the path to keys dot text in our case. 10:01.570 --> 10:14.360 So now without the path let's see what happens so if I try get searches I can see two contract files. 10:14.360 --> 10:15.410 Now if I add 10:19.940 --> 10:30.290 this file keys both text too gets ignored and I try to get status then it's just ignored. 10:30.290 --> 10:31.610 That's final. 10:32.330 --> 10:35.760 And it's not showing up anymore as and trucks. 10:35.840 --> 10:44.930 Now if I do get odd of all files and then try and get stages then I can see that's of course a new file 10:44.960 --> 10:51.090 gets ignored but it doesn't say anything about keys or texts because we are ignoring it though. 10:51.140 --> 10:53.900 Now if I commit the changes using Gates commits 11:01.340 --> 11:07.240 then in the changes it won't say anything about keys or texts because that's inside Gates. 11:07.840 --> 11:08.400 All right. 11:08.420 --> 11:11.790 In the next video you're going to get introduced to get hub.