Git - Why .txt file is not being ignored

I need to ignore TXT file in git. For this I have included * .txt in the .gitignore file. But when I edit something in one of my .txt file git still keeps track of it. Where is the problem or am I doing something wrong. Please help me.

+3


source to share


5 answers


If you've ever committed a text file, git already tracks it. You need to remove it from git so that it is not tracked, then it will properly ignore it.



git rm --cached name.txt

      

+12


source


You may have already made a file to be tracked. You need:



git rm --cached filename

      

+4


source


Gitignore doesn't stop you from tracking files that are already being tracked. You need to remove them from your repo.

find . -name '*.txt' ¦ xargs git rm

      

Must do the trick.

+1


source


I think you added this file .txt

to the intermediate level index before including it .txt

in the file .gitignore

. To ignore this, you must remove this .txt

file from the staging index. To remove it from the hosting index, but not from the working directory, insert the following line:

git rm --cached my_file.txt

      

If that doesn't work, insert:

git rm --cached my_file.txt -f

      

+1


source


Another possible mistake is having a space after the line *.txt

.

0


source







All Articles