WEBVTT

00:06.390 --> 00:13.530
As you remember, Gert, on The X-Files, you explicitly ask it to, but it could happen that you ask

00:13.530 --> 00:16.320
it to track some files by mistake.

00:16.320 --> 00:24.240
For instance, you could issue the command grid at DOT, and as you remember, this command will add

00:24.240 --> 00:28.000
all the files in the repository to be tracked.

00:28.020 --> 00:34.680
We have a way to hide certain files from Git that you know you'll never want it to track.

00:34.710 --> 00:39.460
To do this, we have to add it dot git ignore file.

00:39.480 --> 00:47.490
This configuration file is added to the root directory of the repository and it lists files you don't

00:47.490 --> 00:52.280
want git to track or display as part of git status.

00:52.290 --> 00:57.420
You can add items to the dot git ignore file and commit them.

00:57.420 --> 01:03.720
By the way, all the file is listed in git ignore is not meant to be tracked.

01:03.720 --> 01:10.020
It's possible that you could accidental lee tell git to track a file that's listed in there.

01:10.050 --> 01:13.320
If that happens, you won't get any error message.

01:13.320 --> 01:21.360
This is another reason you should avoid running git at DOD as it may cause files to be tracked by git

01:21.360 --> 01:22.660
unintentionally.

01:22.680 --> 01:32.850
Examples of files that you might want to add to get ignored include such files as dot xy or some dot

01:32.850 --> 01:34.650
db on windows.

01:34.680 --> 01:42.630
Or you could exclude the whole directory the whole repository by adding the directory to this file.

01:42.630 --> 01:48.840
Now let me create a directory called temp and create a file called config.

01:49.290 --> 01:50.190
TXT.

01:50.340 --> 02:00.240
I want git to ignore this directory, this repository and this file so I'll open the dot git ignore

02:00.240 --> 02:07.470
file with nano editor and I'll type temp slash and config txt.

02:07.650 --> 02:14.910
I'll press control x and save the settings and let's try run and get status command now.

02:14.910 --> 02:18.660
And as you can see, these files are not tracked.

02:18.660 --> 02:27.330
The output gives us only the dot git ignore file, although it's advised to add the dot git ignore file

02:27.330 --> 02:28.670
to your repository.

02:28.680 --> 02:32.400
You can even hide the dot git ignore file from git.

02:32.400 --> 02:39.740
Just add a line dot git ignore to the file and get will ignore this file as well.

02:39.750 --> 02:46.200
However, in such a situation the file will only reside in the local copy of the repository.

02:46.200 --> 02:48.560
So that's for you to decide.

02:48.570 --> 02:56.910
You can find many git ignore templates online depending on the framework you are working on, such as

02:56.910 --> 02:57.420
rails.

02:57.420 --> 03:04.680
For example, you may want to browse through this huge collection of dot git ignore files on GitHub.

03:04.680 --> 03:09.630
This templates serve as handy starting points for new projects.

03:09.630 --> 03:18.330
Please keep in mind that you should set up your dot git ignore early because if you add dot git ignore

03:18.330 --> 03:25.680
file at the late stage of a project and then add some file to it which is already committed, it will

03:25.680 --> 03:30.420
still continue to be committed in your repository and tracked by Git.

03:30.420 --> 03:38.490
The only way out in this case is to explicitly track the file in git, after which git will ignore the

03:38.490 --> 03:39.120
file.
