.gitignore does not work for ** / *. xyz

My git project contains .cas files that I don't want to move to the repository. So I added a line

**/*.cas 

to my .gitignore file, but .cas files will still appear in git status . After reading many other posts, I checked the .gitignore entries .gitignore that there are no spaces in white spaces, and that they have unix string modifiers.

Then I executed the following commands as described here: .gitignore does not work

 git rm -r --cached . git add . 

but in vain! git status still reports e.g.

 new file: calc/2_preliminary/1_CFD/7_Calc_Fluent/03_stationary_vof_stationary/mesh_04/run_10000.cas 

Any ideas? I would be very grateful.

Update

.gitignore file contents:

 calc/ 0_BSc_Alvarez/ calc/0_Test/ documentation/Tutorial_Fluent/ literature/ thunderbird/ **/.idea/ .zim **/ND800_* **/*.cas **/*.dat **/*.cdat **/*.uns **/*.msh **/*.bak 

git version 1.7.1

+5
source share
2 answers

You said in the comments that you are using git v1.7.1. The old version of git is a problem. The **/ template was only added in 1.8.2 , so your git just doesn't understand it. In addition, you do not need part **/ , you should only use

 *.cas 
+6
source

Your instructions were partially correct. You started:

 git rm -r --cached . 

which removed junk files from tracked git. But for some reason you decided to add it again using

 git add . 

This led to the appearance of an unwanted file as a new file:

 new file: calc/2_preliminary/1_CFD/7_Calc_Fluent/03_stationary_vof_stationary/mesh_04/run_10000.cas 

The reason this is a new file is because you already told Git to forget about it.

The right course of action would be to only scripts that you really want in the repo that exclude files ending in .cas .

Update:

Try running git rm , but this time include only .cas files:

 git ls-files | grep '\.cas$' | xargs git rm 

Now, if you run git status , you should only see .cas files as deleted. Well, they have not actually been deleted from your local file system, but they will be deleted from the repo.

+4
source

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


All Articles