Up and Running with Git Transcripts
Chapter: Our first git repository
Lecture: Ignoring files in git and editors

Login or purchase this course to watch this video and the rest of the course contents.
0:00 So our app is amazing. It seems like it's working great.
0:04 But notice that when we were here we have these seven files that are to do
0:11 with github that we could commit over in visual studio code.
0:14 It also says there's a bunch of stuff going on here that could be committed.
0:19 And even when we do a commit here,
0:21 there's a unversion files that is untracked the idea files.
0:26 We probably, let's imagine, let's just decide.
0:29 We don't want to commit those at all and we want to get to stop complaining
0:34 to us that here are a bunch of files that need to be changed when I
0:38 look in source tree, I don't want to see a seven.
0:39 I want to see this project is fully committed and saved with these extra files.
0:45 We won't get that so we can in different places.
0:49 Notice there's we go back here,
0:51 there's this git ignore file. Now the git ignore file has all sorts of stuff
0:56 in it. And you're like,
0:57 what is going on here? But notice,
0:59 first of all that we have this virtual environment,
1:02 this 'venv'
1:03 These are dedicated to different operating systems.
1:06 Different versions of python, all sorts of stuff that should never be checked in.
1:11 So we have these statements here,
1:13 let's say git please ignore any directory named venv or .venv
1:20 or any variant there that they've come up with and that's why it's got this grayed
1:25 out or golden out sort of background color and this gold color that says this is
1:32 not this is explicitly ignored by GIT.
1:36 So let's let's go down here and we could you can type in here so I
1:40 could type in here that I don't want to get the idea folder files similarly over
1:46 in visual studio. I could do these as well.
1:49 I could go and open up to git ignore or the way I actually usually like
1:54 to do this is with source tree because it gives you a little bit of help
1:57 on the variations. Like for example,
2:00 one of the things I could do is I could say let's go over here and
2:03 I want to right click. You have all these options.
2:06 Remember when I said that source tree is a UI that does not hide all the
2:11 features of get. It just brings them along in a UI style sometimes that's even
2:15 too intense. This is a little bit of a view into that world,
2:19 but it is, it does give you all the options.
2:21 So let's say we want to ignore this file in the repository.
2:25 Now. I could just say,
2:26 okay, and that would pick this file will never show up as an option to
2:31 be added to git or I could say I just want all the
2:34 iml Files anywhere in the project.
2:36 I could put some custom pattern up here but what I want to do probably is
2:40 just say everything under the .idea folder.
2:43 Please ignore that whatever it is and notice we get the choice of added to this
2:48 repository that will put it into our local git ignored,
2:51 which has a huge benefit or I could ignore it globally.
2:54 So I just never have to think about this again.
2:57 What's the benefit of this repository?
2:59 Only? I'll show you if I do this now we have no other pending files
3:04 from that folder but now we have another change.
3:06 .gitignored has been changed with that addition there at the end to add.
3:10 .idea. The benefit of this is when I check this into github and
3:15 other people get it. If they're also working with PyCharm,
3:19 it will ignore those files for them as well.
3:22 So no one else working with this project might accidentally commit PyCharm.
3:28 Project files either so that I think is a massive benefit.
3:32 So let's go in down here,
3:33 go down here and say ignore PyCharm.
3:37 Project files and if I wanted to do a commit and sync it already,
3:43 I could push this which will take the other changes we have as well.
3:46 These other two there but that's not what I want.
3:49 I want to just commit this one not noticed.
3:51 See that seven up there right here,
3:52 commit zero they're gone because now it knows there's these changes to the ignore files so
3:59 all the files that were there,
4:01 they should be ignored so they disappear from what should be committed,
4:04 syncing that back over to visual studio code.
4:06 You can see now the .idea folder is not lit up as something to commit
4:10 Similarly, over here, when we go and commit in PyCharm,
4:14 there are now no changes to commit because the only files that are there either committed or ignored.