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

1.9 KiB

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. 每次开始前先同步主干
git switch master
git fetch origin
git pull --ff-only origin master
  1. 从最新 master 拉功能分支开发
git switch -c feature/xxx
  1. 开发中频繁提交到功能分支
git add -A
git commit -m "feat: xxx"
  1. 推送功能分支(不要直接推 master
git push -u origin feature/xxx
  1. 合并前,先把你的分支“重放”到最新 master 上
git fetch origin
git rebase origin/master

有冲突就解决后:

git add -A
git rebase --continue
  1. 再合并回 master本地或平台 PR 都可)
    本地合并推荐:
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 aliasgsync, gstart, gfinish),以后 3 条命令就走完整流程。