Conversation
The tracked gitconfig hard-coded a [user] section:
[user]
email = unknown@unknown.com
name = Unknown User
setup_git copies that file over ~/.gitconfig on every run, so every
provisioned machine silently had its git identity replaced by the
placeholder. Commits then get authored as 'Unknown User
<unknown@unknown.com>' with no error and no prompt -- git only refuses
to commit when an identity is absent, not when it is wrong.
Drop the [user] section from the shipped file, and have setup_git carry
the identity across the overwrite:
- read user.name/user.email before the copy and restore them after
- treat the old placeholder values as absent, so machines already
clobbered by a previous run recover instead of keeping them
- let GIT_USER_NAME / GIT_USER_EMAIL override (these can be exported,
or set in config.local once that mechanism lands)
- print the two commands to run when no identity can be determined,
rather than leaving a config that looks populated but is wrong
Verified against throwaway HOMEs: a real identity is preserved; the
placeholder is discarded; a machine with no identity gets the hint; an
explicit GIT_USER_* wins over an existing value; and the aliases from
the shipped gitconfig are still installed in every case.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
🟢 Approval recommended
The changes directly address the identity-clobbering behavior with a small, well-contained update that preserves existing settings and avoids reintroducing placeholder values.
Pull request overview
This PR prevents setup_git from clobbering a user’s Git author identity by removing the hard-coded [user] placeholder from the shipped gitconfig and explicitly preserving/restoring user.name / user.email around the ~/.gitconfig overwrite.
Changes:
- Capture existing
user.name/user.emailbefore overwriting~/.gitconfig, treating the prior placeholder values as “absent”. - Allow
GIT_USER_NAME/GIT_USER_EMAILto override the preserved values, then re-apply them viagit config --global. - Remove the
[user]section from the shippedgitconfigand document the identity behavior inline.
File summaries
| File | Description |
|---|---|
| setup | Preserves/restores Git identity around overwriting ~/.gitconfig, supports env overrides, and prints guidance when identity is missing. |
| gitconfig | Removes hard-coded placeholder identity and documents why the file intentionally lacks a [user] section. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The tracked gitconfig hard-coded a [user] section:
setup_git copies that file over ~/.gitconfig on every run, so every
provisioned machine silently had its git identity replaced by the
placeholder. Commits then get authored as 'Unknown User
unknown@unknown.com' with no error and no prompt -- git only refuses
to commit when an identity is absent, not when it is wrong.
Drop the [user] section from the shipped file, and have setup_git carry
the identity across the overwrite:
clobbered by a previous run recover instead of keeping them
or set in config.local once that mechanism lands)
rather than leaving a config that looks populated but is wrong
Verified against throwaway HOMEs: a real identity is preserved; the
placeholder is discarded; a machine with no identity gets the hint; an
explicit GIT_USER_* wins over an existing value; and the aliases from
the shipped gitconfig are still installed in every case.
🤖 Generated with Claude Code