1
00:00:00,000 --> 00:00:10,000
Last item I want to talk about is a .gitignore.

2
00:00:10,000 --> 00:00:17,000
So .gitignore is about files in a directory that you don't want to be cloned to the git repository.

3
00:00:17,000 --> 00:00:21,000
Think about files that contain sensitive values like passwords.

4
00:00:21,000 --> 00:00:25,000
Excluding these files from being synchronized is not difficult.

5
00:00:25,000 --> 00:00:30,000
You create a text file with the name .gitignore that lists all files that need to be ignored.

6
00:00:30,000 --> 00:00:35,000
A .gitignore file can be added to the current git project directory.

7
00:00:35,000 --> 00:00:39,000
Use the following to create a global .gitignore file.

8
00:00:39,000 --> 00:00:43,000
gitconfig --global core.excludes file

9
00:00:43,000 --> 00:00:49,000
and that allows you to put .gitignore underscore global in your home directory.

10
00:00:49,000 --> 00:00:55,000
And in this file you list files that should be ignored if they occur in any git repository.

11
00:00:55,000 --> 00:01:01,000
So no absolute file names, just the name of the file, the relative name of the file will do.

12
00:01:01,000 --> 00:01:03,000
Let me show you.

13
00:01:03,000 --> 00:01:11,000
So let's do echo password greater than password.txt sensitive value.

14
00:01:11,000 --> 00:01:20,000
And now I'm going to use echo password.txt greater than .gitignore.

15
00:01:20,000 --> 00:01:24,000
I'm just using echo with command output redirection as an editor.

16
00:01:24,000 --> 00:01:29,000
So this creates a .gitignore that lists the name of the file.

17
00:01:29,000 --> 00:01:32,000
Then I'm using git add star.

18
00:01:32,000 --> 00:01:35,000
And, oh, what do we see? Following paths are ignored.

19
00:01:35,000 --> 00:01:37,000
Password.txt.

20
00:01:37,000 --> 00:01:39,000
That's exactly what we need, right?

21
00:01:39,000 --> 00:01:46,000
And git status is showing me that there is an untracked file, the .gitignore.

22
00:01:46,000 --> 00:01:52,000
And git commit minus M, ignore file, edit, going to commit it.

23
00:01:52,000 --> 00:01:55,000
And, yeah, what do we see?

24
00:01:55,000 --> 00:02:00,000
It's not going to commit it because it's a .gitignore and .gitignore stays here.

25
00:02:00,000 --> 00:02:07,000
But in the top of my git commit, I can see that my branch is a head of origin made by one commit.

26
00:02:07,000 --> 00:02:11,000
And that means that I need to git push to synchronize everything.

27
00:02:11,000 --> 00:02:16,000
And now we can see that everything is all right and the .gitignore is included,

28
00:02:16,000 --> 00:02:19,000
so I won't get my password.txt on the remote.

