1 00:00:00,000 --> 00:00:10,000 Last item I want to talk about is the .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:07,000 Let me show you. 13 00:01:07,000 --> 00:01:14,000 So let's do echo password greater than password.txt 14 00:01:14,000 --> 00:01:20,000 sensitive value. And now I'm going to use echo password.txt 15 00:01:20,000 --> 00:01:25,000 greater than .gitignore. 16 00:01:25,000 --> 00:01:29,000 And I'm just using echo with command output redirection as an editor. 17 00:01:29,000 --> 00:01:33,000 So this creates a .gitignore that lists the name of the file. 18 00:01:33,000 --> 00:01:37,000 Then I'm using git add star. 19 00:01:37,000 --> 00:01:42,000 And oh, what do we see? Following paths are ignored password.txt. 20 00:01:42,000 --> 00:01:46,000 That's exactly what we need, right? And git status is 21 00:01:46,000 --> 00:01:50,000 showing me that there is an untracked file with .gitignore. 22 00:01:50,000 --> 00:01:54,000 And git commit minus m ignore file 23 00:01:54,000 --> 00:01:58,000 edit going to commit it. 24 00:01:58,000 --> 00:02:02,000 And yeah, what do we see? It's not going to commit it because it's a .gitignore 25 00:02:02,000 --> 00:02:06,000 and .gitignore stays here. But in the 26 00:02:06,000 --> 00:02:10,000 top of my git commit I can see that my branch is a head of origin 27 00:02:10,000 --> 00:02:14,000 main by one commit. And that means that I need to git push 28 00:02:14,000 --> 00:02:18,000 to synchronize everything. And now we can see that everything is 29 00:02:18,000 --> 00:02:22,000 all right and the .gitignore is included so I won't get my 30 00:02:22,000 --> 00:02:24,000 password.txt on the remote.