skip to Main Content

I checkout the same git repository multiple times on my machine, and open them on several VSCode instances. I do this because I work on different features/bugs simultaneously on the same repository.

This gets soon confusing which folder I have open, so I want to set a different color theme depending on each folder I open. I can usually do this via settings.json, but since I’m working on the same git repository on all folders, it’ll conflict the settings. There’s user’s settings.json, but this only works globally as far as I know. Is there a solution to this?

3

Answers


  1. I do the following for this:

    1. Different branch
    2. Under that, we can edit settings.json.
    3. Since it’s just a matter of visualisation but actually you don’t have to commit it, then never include that file in git add command.
    4. Or if you are keen on using git add . (which basically adds all changes which is a bad practice we should honestly get rid of) then as mentioned in the comments, run git stash and then commit it.

    This should help, let me know if something’s missed by me. Thanks.

    Login or Signup to reply.
  2. You could create a multi-root workspace for each checkout / git worktree, make your repo’s root directory one of the root workspace folders of the multi-root workspace, and then set settings in the .code-workspace file. This approach has limitations: not all settings are available in the scope for .code-workspace files (see the scope section of https://code.visualstudio.com/api/references/contribution-points#Configuration-property-schema). Unfortunately, workbench.colorTheme is not available for configuration at that scope.

    Login or Signup to reply.
  3. Each git worktree may have its own gitignored .code-workspace

    1. Add worktree.code-workspace to .gitignore and commit it.
    2. Create worktree.code-workspace in each worktree.
    3. Open it with VSCode and click "Open workspace" popup which appears if it was opened as file rather then as a workspace
    4. Use johnpapa.vscode-peacock or whatever VSCode extension to change workspace colors easy.
    5. If you already use .code-workspace with a bunch of configs and need your worktrees to sync their settings/whatever, git update-index --skip-worktree worktree.code-workspace. This will break if you change file on upstream, requiring you to manually merge, but will allow downstreaming .code-workspace changes
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search