Skip to content

Commit 4feda53

Browse files
5hal1nclaude
andcommitted
Move git identity out of the tracked config
The repo is going public, so user.name/user.email now live in ~/.gitconfig.local (untracked) and are pulled in via [include]. install.sh generates a template there when it is missing. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
1 parent 7323866 commit 4feda53

2 files changed

Lines changed: 46 additions & 9 deletions

File tree

‎README.md‎

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ git clone <this-repo> ~/dotfiles
1818
1. Homebrew の導入(無ければ)
1919
2. `brew bundle` で `Brewfile` を適用
2020
3. 設定ファイルを `~` 以下にシンボリックリンク
21-
4. `~/ghq` の作成
22-
5. fish をログインシェルに設定(未設定なら。`/etc/shells` 追記に sudo が必要)
21+
4. `~/.gitconfig.local`(git 識別情報)の雛形生成
22+
5. `~/ghq` の作成
23+
6. fish をログインシェルに設定(未設定なら。`/etc/shells` 追記に sudo が必要)
2324

2425
## 構成
2526

@@ -32,6 +33,14 @@ git clone <this-repo> ~/dotfiles
3233
| `git/gitconfig` | `~/.gitconfig` |
3334
| `git/gitignore_global` | `~/.gitignore_global` |
3435

36+
`user.name` / `user.email` は**このリポジトリに含めていない**。公開リポジトリなので、
37+
`~/.gitconfig.local`(git 管理外)に切り出し、`git/gitconfig` の `[include]` から読み込んでいる。
38+
新しいマシンでは `install.sh` が雛形を生成するので、そこを自分の値に書き換える:
39+
40+
```sh
41+
$EDITOR ~/.gitconfig.local
42+
```
43+
3544
リンクは**ファイル単位**で張っている。`conf.d/` や `functions/` をディレクトリごと張ると、
3645
brew が vendor 側に置くファイルと衝突するため。
3746

@@ -85,16 +94,21 @@ Nerd Font 専用のグリフは使っていない。Ghostty は Nerd Font シン
8594
Terminal.app など他のターミナルで豆腐(□)になるのを避けるため。Ghostty 固定運用にするなら
8695
`config/starship.toml` の `[git_branch]` に `symbol = " "` などを足してよい。
8796

88-
## リモートを設定する
97+
## 認証
98+
99+
GitHub の認証は gh のトークンを git の credential helper 経由で使う(`git/gitconfig` に設定済み)。
100+
新しいマシンでは一度だけ:
89101

90102
```sh
91-
cd ~/dotfiles
92-
git remote add origin [email protected]:<user>/dotfiles.git
93-
git push -u origin main
103+
gh auth login
94104
```
95105

106+
`gh auth setup-git` を実行する必要はない。同等の設定が `git/gitconfig` に入っており、
107+
そちらは実行パスを絶対パスで書いていないので Intel Mac でもそのまま動く。
108+
96109
## メモ
97110

98111
- 設定変更は `~/dotfiles` 以下を直接編集する(`~/.config/...` はリンクなので実体は同じ)
99112
- 変更を反映するには**新しいターミナルタブを開く**。起動済みのセッションには反映されない
100113
- `gh auth login` は初回のみ手動で実行する
114+
- 公開リポジトリなので、マシン固有・非公開の設定は `~/.gitconfig.local` 側に置く

‎install.sh‎

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,30 @@ while IFS= read -r line; do
171171
done <<< "$LINKS"
172172

173173
# --------------------------------------------------------------------------
174-
# 4. ghq のルートディレクトリ
174+
# 4. git の識別情報 (リポジトリ管理外)
175+
# --------------------------------------------------------------------------
176+
section "git 識別情報"
177+
178+
GITCONFIG_LOCAL="$HOME/.gitconfig.local"
179+
180+
if [ -e "$GITCONFIG_LOCAL" ]; then
181+
skip "$(basename "$GITCONFIG_LOCAL") は既にあります"
182+
elif [ "$DRY_RUN" = true ]; then
183+
run_note "$GITCONFIG_LOCAL の雛形を生成する"
184+
else
185+
cat > "$GITCONFIG_LOCAL" <<'TEMPLATE'
186+
# このファイルは dotfiles リポジトリの管理外 (公開したくない情報を置く)。
187+
# ~/dotfiles/git/gitconfig の [include] から読み込まれる。
188+
[user]
189+
name = Your Name
190+
191+
TEMPLATE
192+
warn "雛形を生成しました: $GITCONFIG_LOCAL"
193+
warn " → user.name / user.email を自分の値に書き換えてください"
194+
fi
195+
196+
# --------------------------------------------------------------------------
197+
# 5. ghq のルートディレクトリ
175198
# --------------------------------------------------------------------------
176199
section "ghq"
177200

@@ -186,7 +209,7 @@ else
186209
fi
187210

188211
# --------------------------------------------------------------------------
189-
# 5. fish をログインシェルにする
212+
# 6. fish をログインシェルにする
190213
# --------------------------------------------------------------------------
191214
section "ログインシェル"
192215

@@ -227,7 +250,7 @@ else
227250
fi
228251

229252
# --------------------------------------------------------------------------
230-
# 6. サマリ
253+
# 7. サマリ
231254
# --------------------------------------------------------------------------
232255
section "完了"
233256

0 commit comments

Comments
 (0)