Search code examples
gitvisual-studio-codegitignore

Gitignore: Ignore all .vscode directories, but include the top-level launch.json


I want to ignore all .vscode directories that may show up in my repository, except for the top-level one. In that top-level one I want to ignore all files except for the launch.json.

I tried to no extent:

**/.vscode/
!/.vscode/
/.vscode/*
!/.vscode/launch.json
**/.vscode/
!/.vscode/
!/.vscode/launch.json
**/.vscode/
!/.vscode/launch.json
**/.vscode/*
!/.vscode/launch.json
**/.vscode/
/.vscode/!launch.json

Solution

  • I stumbled on this answer and as some sources today claim that its a good idea to commit the launch.json I wanted to provide the correct answer:

    .vscode
    !.vscode/launch.json
    

    (You added a slash after !, so the path was considered absolute).