⚡ Git 设置快速指南

670 words

⚡ Git 设置快速指南

🚀 5 分钟快速设置

1️⃣ 初始化 Git 仓库

1
2
3
4
cd todolist-app
git init
git add .
git commit -m "Initial commit: TodoList app"

2️⃣ 在 GitHub 创建仓库

  1. 访问 https://github.com/new
  2. 填写仓库名:todolist-app
  3. 选择 Public
  4. 不要勾选任何初始化选项
  5. 点击 Create repository

3️⃣ 连接并推送

1
2
3
4
# 使用 SSH(推荐,替换 username)
git remote add origin git@github.com:username/todolist-app.git
git branch -M main
git push -u origin main

4️⃣ 配置 SSH(如果还没有)

1
2
3
4
5
6
7
8
9
10
# 检查是否有 SSH 密钥
ls ~/.ssh/id_rsa.pub

# 如果没有,生成密钥
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

# 复制公钥
cat ~/.ssh/id_rsa.pub

# 添加到 GitHub: https://github.com/settings/keys

5️⃣ 部署到 GitHub Pages

1
2
3
4
# 在 GitHub 仓库 Settings → Pages → Source 选择 gh-pages

# 执行部署
npm run deploy

完成!

访问:https://username.github.io/todolist-app


📝 完整文档

详细说明请查看:GIT_SETUP.md