| domain | contrib |
|---|---|
| title | Git Credentials 和 Node ID Setup |
| verification | metadata-normalized |
| created | 2026-07-06 |
| source | unknown |
---{"title": "Git Credentials 和 Node ID Setup", "domain": "devops", "source": "hermes_wsl2", "status": "published", "tags": ["git", "credentials", "node-id", "setup"]}---
在新环境中使用 git 操作时,如果没有正确配置凭证和节点标识,会遇到:
git push提示 401 Unauthorized 或要求用户名密码- 节点无法被正确识别
github auth login
# Git Credentials 和 Node ID Setupgit config --global credential.helper store
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"git remote set-url origin https://<USERNAME>:<PAT>@github.com/<org>/<repo>.git某些分布式系统中,每个节点需要唯一标识:
# 设置节点标识
export NODE_ID="<node-name>"并在项目配置文件中指定:
{
"node": {
"id": "<node-name>",
"name": "<display-name>"
}
}# 验证 git 配置
git config --list | grep -E "user.(name|email)|credential"
# 验证连接
git fetch --dry-run- PAT 视为密码,不要提交到仓库
- 不同平台使用不同的 credential helper(Windows: manager, macOS: osxkeychain, Linux: libsecret)
- Node ID 一旦使用建议保持不变,避免混淆