Search code examples
gitgit-bashgitignore

How to properly ignore files from git using .gitignore file?


My assignment is requiring me to ignore two folders from git along with their contents. I have created a .gitignore.txt file and typed in the folders' names in the file:

enter image description here

I have also tried the above with a /* at end of file names and without any forward slash or asterisk at all. However, git seems to still recognize these folders. Here is the result I receive each time I use git status command in git-bash.

enter image description here

git is still recognizing these folders since they are within the untracked files, correct? What do I need to do to have git ignore the folders completely?


Solution

  • You've created a file called .gitignore.txt, which is not special to Git in any way. The file must be called exactly .gitignore, with no extension.

    Many Windows programs automatically append a file extension, and Notepad is no different. You're going to be a little better off using a slightly more capable text editor. There are many; any one is fine.

    In the mean time, you can quit Notepad, then do mv .gitignore.txt .gitignore and things should work.