简体   繁体   中英

Set Visual Studio Code as default git editor inside a Docker dev container

Basically my problem is that when working on a development container and trying to set vscode as the git default editor, the terminal won't detect vscode (this is expected behaviour because the main goal of the dev containers is developing in isolation).

在此处输入图片说明

Is there a way to set vscode as the default editor inside a development container?

Note: this is more a question about setting up containers than it is one about setting up Git.

You'd need to have that editor available inside the container, and then while in the container, tell Git to use that editor. That's all very straightforward: just set core.editor appropriately, and set up whatever command line path variable you might need appropriately as well if and as necessary. So we're just left with the puzzle of how to make this the default.

The answer to that is easy too, though. To make it the default , make sure that the container's Git configuration defaults are set that way.

The defaults for Git are:

  • the configuration specified by the system ( git config --system --list ; note that this produces an error message showing where the file is, if the file does not exist; add --show-origin if it does, to find its path-name), but
  • overridden by user --global ( git config --global --list ), but
  • overridden by current repository ( git config --list ), but
  • overridden by command line and/or environment settings.

Since the system config and user global config files can be set up via Docker mounts, these are the obvious places to put the defaults. Simply bind-mount something appropriate. See the Docker documentation for details. Most current Docker systems allow bind-mount for a single file, but if yours doesn't, consider bind-mounting your entire home directory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM