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

相关推荐
ianzh3 小时前
workbuddy-to-dsh使用教程
github
YahirQ4 小时前
技术博客一键多发实战:基于 GitHub Actions 与双引擎的自动化发布流水线
github
恒拓高科WorkPlus5 小时前
企业怎样选择IM即时通讯平台?私有化部署还是SaaS更适合?
网络·github
Maynor在掘金6 小时前
只用 1 张随手拍,在 Claude Code 里做出 15 秒抖音带货视频(配音 + 字幕花字 + BGM,本地出片)
github
littlex8 小时前
复盘分享:「高性价比人生指南」衍生网站,一周 8k+ 用户
github
u1301309 小时前
GitHub 热榜项目:周榜(2026-10-04)
人工智能·github
挖掘狂人9 小时前
Git 从 0 到 1:用一个小项目走完 add / commit / reset / merge / rebase / push
git·后端·github
miofly10 小时前
macOS 本地 AI 搜索工具 SCM 发布 0.2.4 版本,支持多模型照片视频检索
开源·github
codigger10 小时前
Git 三区域模型:把 add、commit、reset、merge 一次讲透
git·github·编程·编程语言
高频因子挖掘机10 小时前
行情监控脚本重启后,怎样快速恢复而不重复拉取数据?
后端·github·api