开发工具配置¶
工欲善其事,必先利其器。本节配置日常开发必备的工具。
1. Git¶
Git 是版本控制系统,几乎所有代码项目都用它管理。
安装¶
# macOS
brew install git
# Ubuntu / Debian
sudo apt install git
# Windows
# 下载安装:https://git-scm.com/download/win
基本配置¶
# 设置用户信息(必须)
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
# 设置默认分支名
git config --global init.defaultBranch main
# 设置编辑器
git config --global core.editor vim # 或 code(VS Code)
生成 SSH 密钥(连接 GitHub)¶
# 生成密钥
ssh-keygen -t ed25519 -C "your.email@example.com"
# 启动 ssh-agent
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
# 复制公钥,粘贴到 GitHub → Settings → SSH Keys
cat ~/.ssh/id_ed25519.pub
# 测试连接
ssh -T git@github.com
常用命令速查¶
git init # 初始化仓库
git clone <url> # 克隆远程仓库
git status # 查看状态
git add . # 暂存所有更改
git commit -m "描述" # 提交
git push origin main # 推送
git pull origin main # 拉取
git branch feature # 创建分支
git checkout feature # 切换分支
git merge feature # 合并分支
git log --oneline # 查看提交历史
2. VS Code¶
VS Code 是最流行的代码编辑器,对 Python 和 ROS 支持极好。
安装¶
# macOS
brew install --cask visual-studio-code
# Linux
sudo snap install code --classic
# Windows
# 下载:https://code.visualstudio.com/
必装扩展¶
| 扩展 | 用途 |
|---|---|
| Python | Python 语法高亮、调试、Linting |
| Pylance | Python 智能补全 |
| Jupyter | Jupyter Notebook 支持 |
| Remote - WSL | 远程连接 WSL2 |
| Remote - SSH | 远程连接服务器 |
| Docker | Docker 容器管理 |
| C/C++ | C++ 语法支持(ROS 节点开发) |
| ROS | ROS 开发支持 |
| GitLens | Git 增强(查看 blame、历史) |
WSL2 中使用 VS Code¶
3. 终端美化(可选)¶
Oh My Zsh¶
# 安装 Zsh(macOS 默认已安装)
sudo apt install zsh # Linux
# 安装 Oh My Zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
常用插件¶
下一步¶
- Python 环境配置 — 配置 Python 开发环境
- Docker 配置 — 安装 Docker