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

相关推荐
今夕资源网6 小时前
AI声音克隆软件 CosyVoice今夕一键整合包解压即用 阿里巴巴通义实验室开源 github斩获22K星标
人工智能·github·多国语言·声音克隆·零样本语音克隆·感情·ai语音克隆
胡萝卜术9 小时前
从聊天模型到本地执行助手:Remote MCP 多工具 Agent 实战
面试·架构·github
慕容引刀11 小时前
告别Commit信息纠结:使用Git AI Commit插件实现规范化提交
人工智能·git·github·visual studio code·visual studio
GoGeekBaird20 小时前
我开源了 BeeWeave,给 AI Agent 搭一个越用越懂你的知识创作台
后端·github
fthux1 天前
GitZip Pro 源码解析:一个 GitHub 文件/文件夹下载扩展是如何工作的(一)整体架构与扩展入口
人工智能·ai·开源·github·open source
第一程序员1 天前
Rust Agent 子进程执行:Command 之前,先定义输入和超时
python·rust·github
2501_936960361 天前
GitHub初步了解
github
wangruofeng1 天前
11 万 Star 的生成式 AI 入门课,Microsoft 做对了什么
github·aigc·ai编程
IOT那些事儿1 天前
GitHub Profile 429: Too Many Requests
github·profile·429
峰向AI1 天前
Agent 看不了视频?这个 7K Star 的开源插件一招搞定
github