Git ignore unignore not working?

I looked at this answer: Unignore sub directories of ignored directories in Git

And as far as I can tell, I am doing the same thing, but git refuses to ignore my directories / files.

These are my rules. I am trying to just get the directories / subdirectories listed, but the whole shared directory is not displayed.

/public/bootstrap/* !/public/bootstrap/bower_components/bootstrap/dist/* !/public/bootstrap/bower_components/bootstrap/dist/**/* !/public/bootstrap/bower_components/bootstrap/less/variables.less 

Any ideas?

+5
source share
3 answers

You can do it as follows. The sentence "You can't unignore more than one level deep per line" is incorrect. You can refer to the answer here .

 /public/bootstrap/** !/public/bootstrap/**/ !/public/bootstrap/bower_components/bootstrap/dist/** !/public/bootstrap/bower_components/bootstrap/less/variables.less 
+8
source

After some reading and lots of trial and error, this works:

 /public/bootstrap/bower_components/jquery /public/bootstrap/bower_components/bootstrap/** !/public/bootstrap/bower_components/bootstrap/dist/ !/public/bootstrap/bower_components/bootstrap/dist/** !/public/bootstrap/bower_components/bootstrap/less/ !/public/bootstrap/bower_components/bootstrap/less/variables.less 

The problem is this line in the docs: "Cannot re-include the file if the parent directory of this file is excluded."

This seems to directly contradict the other answers, but it seems like it works for me.

In my testing, I found that you would ignore like this:

 /public/bootstrap/* 

You cannot unlock more than one level deep in a line.

 # doesn't work !/public/bootstrap/bower_components/bootstrap/ # works !/public/bootstrap/bower_components/ !/public/bootstrap/bower_components/bootstrap/ 
+2
source

Command line that helps to test if you understand correctly: https://git-scm.com/docs/git-check-ignore

Next CLI:

 git check-ignore -v .idea/bbb.txt .idea/workspace.xml .idea/runConfigurations/Android_Debug___ReactNative.xml android/.idea/aaaa.txt android/.idea/runConfigurations/app.xml 

Outputs the following:

 .gitignore:33:**/.idea/** .idea/bbb.txt .gitignore:33:**/.idea/** .idea/workspace.xml .gitignore:35:!**/.idea/runConfigurations/* .idea/runConfigurations/Android_Debug___ReactNative.xml .gitignore:33:**/.idea/** android/.idea/aaaa.txt .gitignore:35:!**/.idea/runConfigurations/* android/.idea/runConfigurations/app.xml 

Please note that the 3rd and 5th lines are successfully ignored (see the "!" Sign).

My .gitignore file:

 **/.idea/** !**/.idea/runConfigurations/ !**/.idea/runConfigurations/* 
0
source

Source: https://habr.com/ru/post/1205305/


All Articles