Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git selectively ignoring despite gitignore file

Tags:

git

gitignore

So, I've set up my global .gitignore file to ignore all files with the .iml ending. However, for some reason it's not ignoring one particular iml file. I've got my ignore file and the

~/projects/dhub
calebsutton$cat /home/calebsutton/.gitignore
*.iml

~/projects/dhub
calebsutton$git status
# On branch DM-481
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   new file:   app/web/src/main/java/com/wellcentive/integration/page/sourcetype/SourceTypeActionPage.java
#   new file:   app/web/src/main/java/com/wellcentive/integration/page/sourcetype/SourceTypeListPage.java
#   new file:   app/web/src/main/java/com/wellcentive/integration/page/sourcetype/grid/SourceTypeListGrid.java
#
# 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:   app/web/src/main/java/com/wellcentive/integration/page/sourcetype/grid/SourceTypeListGrid.java
#   modified:   app/web/web.iml
#
like image 756
CalebJ Avatar asked Dec 20 '25 10:12

CalebJ


1 Answers

Run the command:

git ls-files --others | grep web.iml

to look for that particular file in list of untracked files. If it isn't in that list, then you need to untrack it.

(credit to jthill for this)

git ls-files -ic --exclude-standard

also does what the first command does.

At which point run:

git rm --cached app/web/web.iml

This will remove the web.iml file from your list of tracked files without removing it from the directory.

like image 75
CalebJ Avatar answered Dec 24 '25 11:12

CalebJ



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!