Ubuntu(Orange Pi / RK3588)把工程上传到 GitHub 的完整流程总结(Windows差不多)

1) 安装与基础配置

复制代码
sudo apt update
sudo apt install -y git openssh-client
git config --global user.name "随便填名字"
git config --global user.email "最好填GitHub的邮箱"
git config --global init.defaultBranch main

2) 生成并配置 SSH Key

生成 key:

复制代码
ssh-keygen -t ed25519 -C "你的邮箱"
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519

把公钥复制出来:

复制代码
cat ~/.ssh/id_ed25519.pub

在 GitHub 网页添加:
Settings → SSH and GPG keys → New SSH key(粘贴公钥)

验证:

复制代码
ssh -T git@github.com

3) 若 22 端口超时:让 SSH 走 443(无 VPN 常用解法)

创建或者编辑 ~/.ssh/config

复制代码
mkdir -p ~/.ssh
nano ~/.ssh/config

写入:

复制代码
Host github.com
  HostName ssh.github.com
  User git
  Port 443
  IdentityFile ~/.ssh/id_ed25519
  IdentitiesOnly yes

设置权限并测试:

复制代码
chmod 600 ~/.ssh/config
ssh -T git@github.com

4) GitHub 上创建仓库(repo)

GitHub 页面:New repository

拿到仓库 SSH 地址(创建后提示页面会给),例如:

复制代码
git@github.com:用户名/仓库名.git

5) 本地工程初始化并首次推送

进入工程目录:

复制代码
cd /path/to/your/project
git init
git add .
git commit -m "Initial commit"
git branch -M main
git remote add origin git@github.com:用户名/仓库名.git
git push -u origin main

6) ROS2(colcon 工作空间)必须做的忽略项

通常只提交源码(src/)和必要配置,不提交构建/日志产物。

在 workspace 根目录添加 .gitignore(核心三行):

复制代码
build/
install/
log/

如果这些目录之前已经被提交过,需要取消跟踪(不删本地文件):

复制代码
git rm -r --cached build install log
git commit -m "Ignore colcon artifacts (build/install/log)"
git push

7) 备选:用 HTTPS 推送(如果 SSH 443 也不通)

把远程改成 HTTPS:

复制代码
git remote set-url origin https://github.com/用户名/仓库名.git
git push -u origin main

GitHub 会要求你用 Personal Access Token (PAT) 作为密码(不能用账号密码)。

相关推荐
飞乐鸟1 小时前
Github 3.3k Star!一款开源的PDF工具包!
pdf·github
007张三丰3 小时前
掌握核心!Git最常用的15个命令行:从入门到实战详解
git·gitlab·github·git命令行·常用命令行
民工哥技术之路3 小时前
微软用 Rust 写了个新编辑器!小巧轻量却功能强大,Github 狂揽 13400+ Star
github
前端 贾公子5 小时前
如何在 Github 上规范的提交 PR(图文详解)
github
汪海游龙5 小时前
03.13 AI 精选:1-bit 大模型官方推理框架
github·hacker news
闫记康9 小时前
scp工具
linux·运维·服务器·学习·ssh·github
逛逛GitHub9 小时前
狠狠的 Pua 你的 OpenClaw 小龙虾,这 2 个 GitHub 项目开源了。
github
testresultstomorrow11 小时前
GitHub 代码上传与故障排除实战指南
经验分享·笔记·开源·github
啊巴矲12 小时前
小白从零开始勇闯人工智能:GitHub基础入门(下)
github
研究点啥好呢13 小时前
每日GitHub热门项目推荐 | 2026年3月9日(补充)
ai·开源·github·openclaw