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) 作为密码(不能用账号密码)。

相关推荐
小奏技术9 小时前
为什么 2026 年了,我又写了一个 API 调试工具
github
miofly10 小时前
Kling 4.0 上线 API 调用,支持 30 秒原生音频视频生成
开源·github
miofly10 小时前
山东大学研究:代码智能体的复杂 harness 主要提升 token 消耗而非性能
开源·github
wflynn15 小时前
GitHub 今日推荐|dquickts:能暂停、能存档的 QuickJS
开源·github·c·durable-execution·embeddable·hibernation
miofly18 小时前
GitHub 今日推荐|gpu-unlock-ada:Ada 显卡张量算力翻倍解锁
开源·github
miofly19 小时前
GitHub 周榜趋势速报 | 2026-10-25
开源·github
miofly19 小时前
GitHub 日榜趋势速报 | 2026-10-25
开源·github
u13013021 小时前
GitHub 热榜项目:日榜(2026-10-24)
人工智能·github·1024程序员节
保卫大狮兄1 天前
2小时,我搭了一套仓库出入库管理系统:收货、领料、退料、库存全打通!
wms·github·仓库·入库
沙蒿同学1 天前
不引 Ghostscript:我用纯 Go 给 PDF 做了一场「压缩手术」
前端·后端·github