How to deal with extensive .gitconfig with multiple identities and Visual Studio Code devcontainers?
Answer a question
It seems like Visual Studio Code and it's dev containers copy the .gitconfig upon creation. As I have to manage different identities I've quite an extensive .gitconfig, which load other configuration files conditionally. For example:
[includeIf "gitdir:~/Workspace/github.com/"]
path = .gitconfig-github.com
Of course Visual Studio Code doesn't copy them and even if it wouldn't work as the conditional doesn't apply because it will detect the wrong directory.
Anyhow, is it somehow possible to run git config --get user.name and git config --get user.email outside of the container within the working directory and set it to the devcontainer upon creation?
Update
The problem is it's not possible to retrieve the return values from commands within a docker-compose.yml or Dockerfile to hand it over to the container right?
version: '3'
services:
app:
build:
context: .
dockerfile: Dockerfile
args:
VARIANT: 14
GIT_USERNAME: ${git config --get user.name}
GIT_USERMAIL: ${git config --get user.email}
volumes:
- ..:/workspace:cached
command: sleep infinity
Something like this wouldn't work. Is there a workaround?
Answers
As illustrated by:
- commit 1641597 (Update
docker-compose.ymlfiles to mount.gitconfig) - commit 3ad0b8b (Remove
.gitconfigmount now that its copied)
You would need to modify/patch the container-templates/docker-compose/.devcontainer/docker-compose.yml and others containers/xxx/.devcontainer/docker-compose.yml in order to add any instruction automatically executed by VSCode whencreating a new container.
That path would include a way to select the right config/identity to use in order to modify the mounted .gitconfig accordingly.
更多推荐
所有评论(0)