5

My git project contains .cas files that I do not want to be pushed to the repository. I thus added the line

**/*.cas

to my .gitignore file but .cas files would still appear in git status. After reading through numerous other posts I checked for the .gitignore entries to not have trailing white spaces and that they do have unix line change specifiers.

I then ran the following commands as advised 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 really appreciate it.

Update

.gitignore file content:

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

git version is 1.7.1

Community
  • 1
  • 1
Bastian
  • 901
  • 7
  • 23
  • To ignore all file ending in ".cas" simply specify `*.cas` in your .gitignore. – michas Nov 19 '16 at 10:17
  • besides being more comfortable to write and read, is `*.cas` treated any different from `**/*cas`? – Bastian Nov 19 '16 at 10:32
  • Can you show the entire `.gitignore` file? Also, the output of `git check-ignore -vn --no-index calc/2_preliminary/1_CFD/7_Calc_Fluent/03_stationary_vof_stationary/mesh_04/run_10000.cas`. – Roman Nov 19 '16 at 10:41
  • @Roman, I added the file contents of .gitignore. git version 1.7.1 does not know `check-ignore` and I did not find any equivalent, so I ssh'd to the git folder from my personal computer where I have git version 1.9.1. `git check-ignore -vn --no-index calc/2_preliminary/1_CFD/7_Calc_Fluent/03_stationary_vof_sta‌​tionary/mesh_04/run_‌​10000.cas` then returns `.gitignore:9:**/*.cas "calc/2_preliminary/1_CFD/7_Calc_Fluent/03_stationary_vof_sta\342\200\214\342\200\213tionary/mesh_04/run_\342\200\214\342\200\21310000.cas"` – Bastian Nov 20 '16 at 10:52
  • `git check-ignore` from another version is not helpful. We already established that your version is too old. – Roman Nov 20 '16 at 17:14

2 Answers2

6

You said in comments that you use git v1.7.1. Old git version is the problem. **/ pattern was added only in 1.8.2, so your git just doesn't understand it. Besides, you don't really need the **/ part, you should use just

*.cas
Roman
  • 6,486
  • 2
  • 23
  • 41
4

Your instructions were partially correct. You ran:

git rm -r --cached .

which removed the unwanted files from being tracked by Git. But then for some reason you decided to add it back again using

git add .

This resulted in the unwanted file now appearing 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 it is a new file is because you already told Git to forget about it.

The correct course of action would have been to only stage files you actually want in the repo, which would have excluded files ending in .cas.

Update:

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

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

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

Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
  • This is strange, so I gave it a try. Turns out, `git add` does not add ignored files back after they were deleted from index. Even explicit `git add ignored-file` gives "The following paths are ignored by one of your .gitignore files: ignored-file; Use -f if you really want to add them." – Roman Nov 19 '16 at 10:36
  • I see thank you. Is there not a way of adding an entire folder or all folders via `.` and still have contained `.cas` files ignored? – Bastian Nov 19 '16 at 10:37
  • @roman I only have git version 1.7.1 here, could this be the reason? – Bastian Nov 19 '16 at 10:38
  • Before running into the current mess I had another issue with git claiming that tons of files `... .msh` would have been renamed to `... .jpg` which was not possibly the case. Maybe I should start over with a clean `clone`? – Bastian Nov 19 '16 at 10:41