一、初始化本地仓库
cd ~/your-robot-project
git init
git add .
git commit -m "Initial commit"
二、配置 Git 身份
git config --global user.name "你的名字"
git config --global user.email "你的邮箱@xxx.com"
三、使用 SSH 免密推送
ssh-keygen -t ed25519 -C "your_email@example.com"
# 按回车默认保存,不设密码
cat ~/.ssh/id_ed25519.pub # 复制输出内容
去 GitHub → Settings → SSH and GPG keys → 新建 SSH Key → 粘贴
验证是否成功
ssh -T git@github.com
# 看到 "Hi 你的用户名! You've successfully authenticated" 就对了!
四、关联远程仓库
git remote add origin git@github.com:你的用户名/仓库名.git
git branch -M main #将本地分支更改为main
git push -u origin main #推送到远程
如果提示 fetch first,说明远程有 README,执行:
git pull origin main --allow-unrelated-histories
git push -u origin main
1180

被折叠的 条评论
为什么被折叠?



