0

When using Visual Studio Code (vscode) devcontainers the extension automatically sets vscode as the git editor. It does this by setting the GIT_EDITOR env var.

To prove it, I ran:

docker run --rm mcr.microsoft.com/devcontainers/base:bookworm bin/bash -c 'echo ${GIT_EDITOR}'

which didn't return anything. To prove that it would return a value if it were set run

docker run --rm mcr.microsoft.com/devcontainers/base:bookworm bin/bash -c 'echo ${HOSTNAME}'

which will return a command (proving that my docker run command is correct).

screenshot of running the aforementioned commands

However, if I use that image for my devcontainer in .devcontainer/devcontainer.json:

{
    "name": "Debian",
    "image": "mcr.microsoft.com/devcontainers/base:bookworm"
}

and then inside the devcontainer run:

echo $GIT_EDITOR

it returns:

code --wait

screenshot of running echo $GIT_EDITOR inside the devcontainer

Clearly the devcontainers extension is setting GIT_EDITOR. However I don't want to use vscode to edit git messages, I prefer to use the command-line. How can I stop it from doing so? Obviously I can simply

unset GIT_EDITOR

but its rather tedious to do that over and over again. I wonder if there's a setting that I can set in devcontainer.json that prevents GIT_EDITOR from getting set?

jamiet
  • 10,501
  • 14
  • 80
  • 159

1 Answers1

0

This solves it:

{
    "name": "Debian",
    "image": "mcr.microsoft.com/devcontainers/base:bookworm",
    "containerEnv": {
      "GIT_EDITOR": "vi"
    }
}

However I don't really want to specify anything, I'd rather each user of the devcontainer set it to whatever they want without mandating what the default should be. Hence why I'd just like to configure the devcontainer to simply not set GIT_EDITOR.

jamiet
  • 10,501
  • 14
  • 80
  • 159