Git ignore does not ignore netbeans personal files

When I execute git status, netbeans private.xml creates problems, I tried to add that there are several ways to ignore git. but gitignore just doesn't ignore it.

git status On branch master Your branch is up-to-date with 'origin/master'. Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: .gitignore modified: nbproject/private/private.xml ... 

My git ignore file

 node_modules/ dist/ *.log nbproject/private/* *.bak *.orig *~ *.log *private.xml 

Tried both nbproject / private / * as well as * private.xml in the same file.

+5
source share
2 answers

A file that is already being tracked will not be ignored: you must first remove it from the index.

 git rm --cached private.xml git add -u . git commit -m "Record deletion of private.xml from the index" 

( --cached make sure the file remains on disk)

Then you can add it to .gitignore (no need for '*')

 private.xml 

Note: whenever a file is ignored or not ignored, you can check which .gitignore rule applies with:

 git check-ignore -v -- private.xml 
+13
source

Your file has already been added to the git repository.
After adding a file (not tracked), adding it to .gitignore will not ignore it from the moment it is already in the repo, so you need to delete it from the repository, commit the removal of the file, and then it will be ignored.

See VonC code above for how to do this.

It is important to understand that after the file is already executed, adding it to git ignore will not ignore it.

+1
source

All Articles