I have configured a .dockerignore file and also a .gitignore. I want docker to ignore the .vscode directory but I am trying to add this directory to git.

Demo

$ git add .vscode/
The following paths are ignored by one of your .gitignore files:
.vscode
hint: Use -f if you really want to add them.
hint: Turn this message off by running
hint: "git config advice.addIgnoredFile false"

I am certain that I did not add .vscode to the .gitignore file?

$ cat .gitignore
# Node.js dependencies
**/*/node_modules/
**/*/npm-debug.log*

# Build output
**/*/dist/**/*
**/*/tmp/
**/*/temp/

# Environment files
**/*.env.

# OS files
**/*.DS_Store
**/*Thumbs.db

# Optional: logs
**/*/logs/
**/*.log

# Optional: TypeScript
**/*.tsbuildinfo
$ cat .dockerignore
**/*.md
**/*.env
**/*/.gitignore
**/*/node_modules
**/*/dist
**/*.yaml
**/*.yml
**/*.log
**/*.DS_Store
**/*.vscode

Solution

Follow the advice from the error message and force add the file.

$ git add -f .vscode/

It does not have to be so complex, git considers everyone's ignore file (*.*ignore), it should not...