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

相关推荐
打妖妖灵滴哪吒8 小时前
github创建远程仓库+推送代码(图文版)
github
笨鸟先飞,勤能补拙8 小时前
AI 赋能网络安全:技术全景、成熟度评估与实战案例
人工智能·python·安全·web安全·网络安全·sqlite·github
笨鸟先飞,勤能补拙11 小时前
AI 赋能网络安全领域深度剖析
网络·人工智能·windows·安全·web安全·网络安全·github
gwf21613 小时前
SSD读写速度深度解析:顺序读写vs随机读写、IOPS、延迟,你的硬盘性能到底怎么看?
git·嵌入式硬件·缓存·github·智能硬件
笨鸟先飞,勤能补拙19 小时前
下一个十年:网络安全正在被重写
网络·人工智能·安全·web安全·网络安全·github
潘正翔20 小时前
k8s进阶_Harbor镜像仓库
git·云原生·容器·kubernetes·gitee·github
vibecoding7720 小时前
GitHub 2026 年 7 月热榜:累计 Star 总榜与月度飙星榜
人工智能·github·ai编程
Pniubi20 小时前
Gitee&GitHub同步仓库教程
gitee·github
TunerT_TQ21 小时前
GitHub深度工程评测:AI 系统提示词泄露知识库深度评测:6万星system_prompts_leaks情报资产背后,藏着什么?
人工智能·chatgpt·github·提示词工程·#valhalla静态工程审阅·systemprompt·大模型工程
Python私教21 小时前
GitHub Actions 实战:把测试、密钥扫描与 Docker 镜像检查接入 CI
ci/cd·docker·github·devsecops·github actions