0

I'm frequently working in repositories I do not own (typically open source things). I often want to run dev containers in VS Code as part of my workflow. However, VS Code creates a .devcontainers/ directory for the configuration. For my own repos, this would be a good thing. I would like to have those config files checked into Git so I can track them and share them with other contributors. But for repos I do not own, it's not great. I'd much rather have them somewhere else, like in my home directory.

Is it possible to get VS Code to keep the .devcontainers/ directory outside of the repo I have opened in the dev container?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
lindhe
  • 806
  • 2
  • 14
  • 32
  • 1
    I'd like to understand what you mean when you say `you do not own`. _Every_ local repo that you have..... you _own_ them.... they are _yours_ to do as you please... nothing that you do on them will affect anybody else's repos. – eftshift0 Aug 02 '23 at 18:07
  • 1
    I think lindhe is talking about creating your own GitHub repository vs. contributing to someone else's repo – nate-thegrate Aug 02 '23 at 18:09
  • @eftshift0: Yeah, what @nate-thegrate says. I mean that I should not commit the `.devcontainers/` dir to the repo since it's a repo I am not the maintainer of, so that dir just hangs around like a nobody in my Git tree. :P – lindhe Aug 02 '23 at 21:51

1 Answers1

0

Luckily there's a super convenient solution: add .devcontainers/ to the .gitignore file.

(If there isn't already a .gitignore file in the repo, you would need to create one.)

nate-thegrate
  • 378
  • 2
  • 13
  • This is not the answer I was looking for, but it is the solution I am going for. More specifically: I _cannot_ add it to the `.gitignore` for the repo, since that too would be an unasked for contribution to someone else's repo. But what I have done is to add it to my [global `.gitignore`](https://www.git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#_core_excludesfile) file (in my case [`~/.gitignore_global`](https://github.com/lindhe/dotfiles/blob/0800d26851970672bbf7716a60faa8caf1ac0028/.gitignore_global#L39). – lindhe Aug 02 '23 at 21:57
  • This will make it so that it's ignored by default for me, but if a repo I clone already have a `.devcontainers/` committed, it will of course stay tracked. And if I would like to commit it some time, I'll just have to do `git add -f .devcontainers/`. – lindhe Aug 02 '23 at 21:58