You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nudt-compiler-cpp/command.md

78 lines
1.9 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

## Lab1
# 1.构建
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCOMPILER_PARSE_ONLY=ON
cmake --build build -j "$(nproc)"
# 2.单例查看
./build/bin/compiler --emit-parse-tree test/test_case/functional/simple_add.sy
# 3.批量检查
find test/test_case -name '*.sy' | sort | while read f; do ./build/bin/compiler --emit-parse-tree "$f" >/dev/null || echo "FAIL $f"; done
核心原则:不要在“落后于远端 master”的本地 master 上直接开发和提交。
你以后按这套流程,基本就不会分岔。
**日常标准流程**
1. 每次开始前先同步主干
```bash
git switch master
git fetch origin
git pull --ff-only origin master
```
2. 从最新 master 拉功能分支开发
```bash
git switch -c feature/xxx
```
3. 开发中频繁提交到功能分支
```bash
git add -A
git commit -m "feat: xxx"
```
4. 推送功能分支(不要直接推 master
```bash
git push -u origin feature/xxx
```
5. 合并前,先把你的分支“重放”到最新 master 上
```bash
git fetch origin
git rebase origin/master
```
有冲突就解决后:
```bash
git add -A
git rebase --continue
```
6. 再合并回 master本地或平台 PR 都可)
本地合并推荐:
```bash
git switch master
git pull --ff-only origin master
git merge --ff-only feature/xxx
git push origin master
```
`--ff-only` 的好处是:只允许线性历史,能最大限度避免分叉和脏 merge。
---
**你这次分岔的根因**
你的本地 master 没先追上远端 master远端有新提交然后直接 merge/push导致出现两个方向的提交历史。
---
**三条硬规则(记住就行)**
1. 不在落后状态的 master 上开发。
2. 合并前一定 `fetch + rebase origin/master`
3. 推 master 前先 `pull --ff-only`,失败就先处理,不要强推。
---
如果你愿意,我可以给你一份适配你仓库的 Git alias`gsync`, `gstart`, `gfinish`),以后 3 条命令就走完整流程。