包含 CodeAgent 前后端源码、SKILLS、MCP、demo 代码与工作区文档。 排除依赖缓存、运行数据、备份与二进制附件,规则见 .gitignore。 Co-Authored-By: Claude Code <[email protected]>
3.6 KiB
3.6 KiB
一、新建 GitHub 空仓库(获取仓库地址)
-
GitHub 主页右上角,点击 + 号按钮 →
New repository -
填写仓库信息:
- Repository name:项目名,如
jetrun_iot/agent(和本地文件夹对应) - Description(可选):项目描述,可留空
- 仓库可见性:勾选
Public - ❗重要:不要勾选 Add a README file / Add .gitignore/ Add license(保持仓库为空,否则推送会冲突)
- Repository name:项目名,如
-
点击底部
Create repository创建仓库 -
创建成功后,页面绿色按钮
Code→ 选择 HTTPS,复制仓库地址,示例:
https://github.com/SweetieHenry/jetrun_iot.git
提示:A、B 两个项目需要分别创建 2 个独立仓库,不可混在同一个仓库。
二、生成 PAT (Classic) 个人访问令牌
- 右上角头像
SweetieHenry→ 下拉菜单选择Settings - 页面左侧滚动到底部,点击
Developer settings - 左侧菜单选择
Personal access tokens→Tokens (classic) - 点击
Generate new token (classic) - 令牌配置:
- Note:备注,例如
windows-git-push(标记用途,方便后续识别) - Expiration:有效期,推荐选择
No expiration(永久有效) - Scopes(权限范围):只勾选
repo(完整仓库权限),其余全部取消勾选
- Note:备注,例如
- 拉到页面最下方,点击
Generate token生成令牌 - ⚠️紧急提醒:生成页面会展示一长串字符串,立刻复制保存到记事本,一旦页面刷新,该令牌无法再次查看,丢失只能重新生成。
三、推送代码完整命令
3.1 首次推送(新仓库)
# 1. 进入项目目录
cd D:\Agent\agent
# 2. 配置代理(Clash 用户,只需执行一次)
git config --global http.proxy http://127.0.0.1:7897
git config --global https.proxy http://127.0.0.1:7897
# 3. 初始化 Git(只需一次)
git init -b main
# 4. 添加代码(三选一)
git add . # 全部改动
git add backend frontend .gitignore # 指定目录/文件
# 5. 提交
git commit -m "feat: 项目初始提交"
# 6. 关联远程仓库(只需一次,替换成你的仓库地址)
git remote add origin https://github.com/你的用户名/仓库名.git
# 7. 首次推送
git push -u origin main
3.2 日常推送(已初始化的仓库)
# 一句话版(最快)
cd D:\Agent\agent && git add . && git commit -m "feat: 你的描述" && git push
# 分步版
cd D:\Agent\agent
git add . # 或 git add 指定文件
git commit -m "feat: 你的描述"
git push
3.3 Commit Message 规范
git commit -m "feat: 新增XX功能" # 新功能
git commit -m "fix: 修复XX问题" # 修 Bug
git commit -m "refactor: 重构XX模块" # 重构
git commit -m "docs: 更新XX文档" # 文档
git commit -m "chore: 更新依赖/配置" # 杂项
3.4 常见问题
| 问题 | 解决方案 |
|---|---|
Failed to connect to github.com port 443 |
配置代理(见 3.1 第 2 步)或重试 |
error: src refspec main does not match any |
先 git commit 再 git push |
! [rejected] main -> main (fetch first) |
执行 git pull --rebase origin main 后重试推送 |
| 提示输入密码 | 填 PAT(不是 GitHub 账号密码) |
3.5 安全提醒
.env(含 API 密钥)已在.gitignore中排除,永远不会入库- PAT 只在推送时使用,不要写入任何代码文件
- PAT 泄露后立即到 GitHub 轮换:
Settings → Developer settings → Personal access tokens