Skip to content

Auto-configure Git identity in WSL distros from Windows host#9

Open
klemenza wants to merge 7 commits into
qwatts-dev:masterfrom
klemenza:clean-git-identity
Open

Auto-configure Git identity in WSL distros from Windows host#9
klemenza wants to merge 7 commits into
qwatts-dev:masterfrom
klemenza:clean-git-identity

Conversation

@klemenza
Copy link
Copy Markdown

Summary

Automatically configures Git identity (user.name and user.email) inside WSL distros by reading the values from the Windows host's Git config during bootstrap.

Problem

When developers first use Git inside a newly created WSL distro, they encounter this message:

*** Please tell me who you are.
Run
  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

This requires manual configuration even though the developer already has Git configured on their Windows host.

Solution

  • Read git config --global user.name and user.email from Windows during bootstrap
  • Inject these values into the WSL setup script using placeholders (similar to WIN_USERNAME_PLACEHOLDER)
  • Automatically run git config --global commands for the admin user inside the distro
  • Display configuration status in console output

Changes

  • Added Git config reading from Windows host via exec.Command("git", "config", ...)
  • Added Git configuration commands to bootstrap script
  • Added placeholder replacement for GIT_USER_NAME_PLACEHOLDER and GIT_USER_EMAIL_PLACEHOLDER

Testing

Verify Git is configured in WSL

wsl -d trellis-<site> -- git config --global user.name
wsl -d trellis-<site> -- git config --global user.email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant