✅ SSH密钥已配置完成!
你已经成功配置了SSH密钥,可以无需密码/Token推送代码到GitHub。
# 测试SSH连接
ssh -T git@github.com
# 应该看到:
# Hi tuobi2! You've successfully authenticated, but GitHub does not provide shell access.# 查看SSH密钥
ls -la ~/.ssh/
# 应该看到:
# id_ed25519 # 私钥 (不要分享!)
# id_ed25519.pub # 公钥 (已添加到GitHub)cd /Users/lijiepeng/python3
git push origin maincd /Users/lijiepeng/python3
./push_ssh.shcd /Users/lijiepeng/python3
./push_to_github.shgit config --list | grep -E "(user\.|remote\.|core\.)"user.name=lijiepeng
user.email=155253629@qq.com
remote.origin.url=git@github.com:tuobi2/python3-learning.git
# 设置用户名
git config --global user.name "你的名字"
# 设置邮箱
git config --global user.email "你的邮箱"
# 设置默认编辑器
git config --global core.editor "vim"
# 设置自动换行
git config --global core.autocrlf input- 远程仓库:
git@github.com:tuobi2/python3-learning.git - 本地分支:
main - 认证方式: SSH密钥
# 测试推送
cd /Users/lijiepeng/python3
git push --dry-run origin main
# 实际推送
git push origin main# 1. 拉取最新代码
git pull origin main
# 2. 创建新分支
git checkout -b feature/new-feature
# 3. 开发代码
# ... 编写代码 ...
# 4. 提交更改
git add .
git commit -m "添加新功能"
# 5. 推送到GitHub
git push origin feature/new-feature
# 6. 创建Pull Request
# 在GitHub网站上操作# 1. 检查SSH代理
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
# 2. 测试连接
ssh -T git@github.com
# 3. 检查GitHub公钥
# 访问: https://github.com/settings/keys# 1. 检查远程仓库
git remote -v
# 2. 检查分支
git branch -a
# 3. 拉取最新代码
git pull origin main --rebase
# 4. 强制推送(谨慎使用)
git push -f origin main# 检查文件权限
ls -la ~/.ssh/
# 修复权限
chmod 600 ~/.ssh/id_ed25519
chmod 644 ~/.ssh/id_ed25519.pub- Pro Git 中文版 - 免费的Git权威指南
- GitHub Learning Lab - 交互式GitHub学习
- Oh Shit, Git!?! - Git常见问题解决
- GitHub Docs - 官方文档
- GitHub Skills - 技能学习
# 使用约定式提交
git commit -m "feat: 添加新功能"
git commit -m "fix: 修复bug"
git commit -m "docs: 更新文档"
git commit -m "style: 代码格式"
git commit -m "refactor: 代码重构"
git commit -m "test: 添加测试"
git commit -m "chore: 构建过程"main- 主分支,稳定版本develop- 开发分支feature/*- 功能分支bugfix/*- 修复分支release/*- 发布分支
- 创建Pull Request
- 请求代码审查
- 通过CI/CD检查
- 合并到主分支
- ✅ 私钥 (
id_ed25519) 不要分享给任何人 - ✅ 公钥 (
id_ed25519.pub) 可以添加到GitHub - ✅ 使用强密码保护私钥
- ✅ 定期更新密钥
- 检查本指南的相关章节
- 查看GitHub官方文档
- 搜索Stack Overflow
- 在GitHub Issues中提问
- GitHub: https://github.com/tuobi2
- 仓库: https://github.com/tuobi2/python3-learning
- Issues: https://github.com/tuobi2/python3-learning/issues
现在你可以轻松地使用SSH推送代码到GitHub! 🚀