Git config
Use your host Git config in the container: your identity, settings and global ignore file.
Set up
Use the files in examples/guides/git-config:
# yaml-language-server: $schema=https://isodev.dyszkiewicz.me/config.schema.json
# Your host Git config: identity, settings and global ignore file.
image: isodev-git-config:latest
build:
context: image
volumes:
# Your Git settings, included by hooks/git.sh.
- type: bind
source: ~/.gitconfig
target: /run/secrets/host-gitconfig
read_only: true
# Optional: your global ignore file, the one `git config --global
# core.excludesFile` names, or ~/.config/git/ignore when that's unset.
- type: bind
source: ~/.config/git/ignore
target: /run/secrets/host-gitignore
read_only: true
lifecycle:
on_create:
scripts:
- file: hooks/git.shFROM ubuntu:24.04
ARG DEBIAN_FRONTEND=noninteractive
# mise installs tools to ~/.local/share/mise and puts them on PATH through its
# shims. /usr/local/bin comes first, so files mounted there win.
ENV PATH=/root/.local/bin:/usr/local/sbin:/usr/local/bin:/root/.local/share/mise/shims:/usr/sbin:/usr/bin:/sbin:/bin
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates curl git \
&& rm -rf /var/lib/apt/lists/*
# mise, which installs the tools.
RUN curl -fsSL https://mise.run | MISE_INSTALL_PATH=/usr/local/bin/mise sh#!/bin/sh
# Runs once in each new container.
set -eu
# Use the host's Git identity and settings, while keeping the container's own
# ~/.gitconfig writable.
git config --global include.path /run/secrets/host-gitconfig
# Optional: commit as someone else, for example a bot account. Settings after
# the include override the host's.
# git config --global user.name 'Example Bot'
# git config --global user.email 'bot@example.com'
# Optional: use the host's global ignore file. This overrides the host's
# core.excludesFile, whose path may not exist in the container.
git config --global core.excludesFile /run/secrets/host-gitignoreYour ~/.gitconfig must exist on the host. The container includes it instead of copying it, so changes on the host apply right away, and the container can still add its own settings.
To commit as someone else, for example a bot account, uncomment the identity in hooks/git.sh. For a GitHub App’s bot identity, see GitHub authentication.
Global ignore file
The container uses your host’s global ignore file, so files you never commit, such as Paseo’s paseo.json, stay out of commits in the container too. Mount the file your host Git uses: git config --global core.excludesFile prints it, and Git uses ~/.config/git/ignore when that’s unset. hooks/git.sh points core.excludesFile at the mounted copy, because the host’s path may not exist in the container.
The file is mounted on its own, so if your editor saves it by replacing the file, containers see the change after isodev up --recreate. If you don’t use a global ignore file, remove its mount and its line in hooks/git.sh.
Use it
isodev up --recreate
isodev exec git config user.nameTrade-offs
- Host settings must work in the container. Settings that point to host paths or programs, such as a credential helper, may not resolve there.