I solved my problem doing the following:
First of all, I am a windows user, but i have faced similar issue. So, I am posting my solution here.
There is one simple reason why sometimes the .gitignore doesn`t work like it is supposed to. It is due to the EOL conversion behavior.
Here is a quick fix for that
Edit > EOL Conversion > Windows Format > Save
You can blame your text editor settings for that.
For example:
As i am a windows developer, I typically use Notepad++ for editing my text unlike Vim users.
So what happens is, when i open my .gitignore file using Notepad++, it looks something like this:
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# See https://help.github.com/ignore-files/ for more about ignoring files.
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
*.dll
*.force
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
If i open the same file using the default Notepad, this is what i get
## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. ## ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore # See https://help.github.com/ignore-files/ for more about ignoring files. # User-specific files *.suo *.user *.userosscache
So, you might have already guessed by looking at the output. Everything in the .gitignore has become a one liner, and since there is a ## in the start, it acts as if everything is commented.
The way to fix this is simple:
Just open your .gitignore file with Notepad++ , then do the following
Edit > EOL Conversion > Windows Format > Save
The next time you open the same file with the windows default notepad, everything should be properly formatted. Try it and see if this works for you.
/bin/
folder still shows when I do agit status
. I haven't changed those files since I added the.gitignore
– Poyang.gitignore
, because if it'sgitignore
(without dot) - it won't work. ;) If it helped: you're welcome. – Farewell