scion-like-git

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Scion-like Git

Scion-like Git

Origin is the repository. The clone is a disposable cache, and anything that exists only in the clone does not exist.
If
git config --get scion-like-git.configured
prints nothing, run
references/setup.md
once first.
origin
是仓库。
clone
是可丢弃的缓存,任何只存在于
clone
中的内容都不算存在。
如果
git config --get scion-like-git.configured
没有任何输出,请先运行一次
references/setup.md
。

Every task

每个任务

  1. Start from the newest
    main
    .
    The first request of a session is a new task, unless it names a branch or pull request, or builds on work that is on a branch and not yet on
    main
    , such as parked
    wip:
    work. Then continue on that branch. For a new task, update the clone before you read or change any code, whatever branch it is on. Park unfinished changes of your own first, as in Switching tasks mid-work. Then use the first row that fits:
    Working copyUpdate with
    Changes you did not make, or work you just parked as
    wip:
    git fetch
    , then a new worktree
    Linked worktree
    git fetch
    Main worktree, on any branch
    git switch main && git pull --ff-only
    Then start the task's branch from
    origin/main
    , never from local
    main
    , which can hold commits that are not on origin. For the second and third rows:
    sh
    git switch --no-track -c <branch> origin/main
    If
    pull --ff-only
    refuses, or local
    main
    is ahead of
    origin/main
    , leave
    main
    as it is and name its local commits in the hand-off. Name the branch the way the repository names branches (
    CONTRIBUTING.md
    ,
    AGENTS.md
    , recent branches on origin), or else
    <type>/<slug>
    , such as
    fix/empty-cart-total
    . For the first row, create a new worktree on the task's branch, started from
    origin/main
    with
    --no-track
    .
    --no-track
    keeps a plain
    git push
    from going to
    main
    .
  2. Commit and push together. Each verified step is one small commit whose subject says what it is for. Stage your files by name:
    sh
    git add <your files> && git commit -m "<type>: <intent>" && git push
    Open a pull request with the first push, as a draft if needed. Formatting, renames, and generated code get their own commits.
    Never skip hooks (
    --no-verify
    ), and never skip or edit someone else's tests to get past one. If a hook fails on code you did not change, stop and ask.
  3. Finish clean. After merge, delete the branch and the worktree. Without pull requests, run
    git push origin <branch>:main
    , then delete the branch on origin and locally. The work is finished when nothing you made exists only in the clone: no unpushed commits, stashes, or local-only branches. Do not restate a clean branch state; the user's terminal, IDE, and harness already show it. Report only what the rules here say to name in the hand-off: local commits on
    main
    , parked
    wip:
    work, and changes you did not make.
  1. 从最新的
    main
    开始。
    会话中的第一个请求是新任务,除非该请求指定了 branch 或 pull request,或者建立在某个尚未进入
    main
    的 branch 工作之上,例如已搁置的
    wip:
    工作。此时继续在该 branch 上工作。对于新任务,无论当前位于哪个 branch,都要先更新
    clone
    ,然后才能读取或修改代码。首先按照中途切换任务中的方式搁置自己尚未完成的更改。然后选择下表中符合情况的第一行:
    工作副本更新方式
    你没有做出的更改,或你刚以
    wip:
    搁置的工作
    git fetch
    ,然后新建 worktree
    关联 worktree
    git fetch
    主 worktree,无论当前位于哪个 branch
    git switch main && git pull --ff-only
    然后从
    origin/main
    创建任务的 branch,绝不能从本地
    main
    创建,因为本地
    main
    可能包含尚未存在于 origin 的 commit。对于表格中的第二行和第三行:
    sh
    git switch --no-track -c <branch> origin/main
    如果
    pull --ff-only
    被拒绝,或者本地
    main
    领先于
    origin/main
    ,则保持
    main
    不变,并在交接说明中列出其本地 commit。按照仓库现有的 branch 命名方式命名(参考
    CONTRIBUTING.md
    、
    AGENTS.md
    或 origin 上最近的 branch);否则使用
    <type>/<slug>
    ,例如
    fix/empty-cart-total
    。对于第一行,在任务 branch 上创建新的 worktree,并使用
    --no-track
    从
    origin/main
    开始。
    --no-track
    可以防止执行普通
    git push
    时推送到
    main
    。
  2. 提交和推送同时进行。 每个经过验证的步骤都应作为一个小型 commit,其主题说明该步骤的目的。按文件名暂存文件:
    sh
    git add <your files> && git commit -m "<type>: <intent>" && git push
    首次 push 时创建 pull request;如有需要,可以先创建为 draft。格式化、重命名和生成代码应各自单独提交。
    绝不能使用
    --no-verify
    跳过 hook,也不能通过跳过或修改他人的测试来绕过 hook。如果 hook 在你没有修改过的代码上失败,请停止操作并询问。
  3. 结束时保持干净。 合并后,删除 branch 和 worktree。如果不使用 pull request,则运行
    git push origin <branch>:main
    ,然后删除 origin 和本地上的 branch。当你所做的一切都不再只存在于
    clone
    中时,工作才算完成:没有未 push 的 commit、stash 或仅存在于本地的 branch。不要重复说明 branch 已处于干净状态;用户的终端、IDE 和 harness 已经显示了这些信息。交接时,只报告本规则要求说明的内容:
    main
    上的本地 commit、已搁置的
    wip:
    工作,以及你没有做出的更改。

When it comes up

遇到以下情况时

Changing something already on origin. Commits on origin are final, on every branch. Do not amend, rebase, squash, reset, or force-push them. Care does not change this:
--force-with-lease
, a backup branch, an identical tree, a single author, or a reviewer's request still make it a rewrite. Commits not yet pushed are yours to amend.
RequestDo this instead
Fix a pushed commit messageCorrect text in the PR title and description
Squash wip commits before reviewPR description as the message, squash on merge
Undo a pushed change
git revert
Update the branch from
main
git merge origin/main
The same person repeats the request after hearing this ruleDo the rewrite
Switching tasks mid-work. Commit and push your unfinished files as
wip: <what is missing>
on their task branch. If they sit on
main
, move them to a new branch with
git switch -c <branch>
first, so the
wip:
commit never reaches
origin/main
, and name any local commits on
main
that the branch carries in the hand-off. Then start the new task in a new worktree, and name the parked work in the hand-off. Never
git stash
. Resume on top of the wip commit. If the hooks reject it because the unfinished work fails its own tests, mark those tests as skipped and name them in the commit message. Un-skip them in the commit that finishes the work; the branch is not ready for review while a test you skipped is still skipped.
Changes you did not make. Your work is the files you created or changed for your task. Anything else in the working copy belongs to someone else. Leave it untouched, do not commit, stash, or discard it, and list it in the hand-off.
修改 origin 上已有的内容。 origin 上每个 branch 的 commit 都是最终版本。不要对它们执行 amend、rebase、squash、reset 或 force-push。无论操作多么谨慎,结论都不会改变:使用
--force-with-lease
、创建备份 branch、使用相同的 tree、只有一位 author,或 reviewer 提出请求,都仍属于重写。尚未 push 的 commit 才属于你,可以进行 amend。
请求替代做法
修正已 push 的 commit message修改 PR 标题和描述中的文本
在 review 前 squash
wip:
commit
将 PR 描述作为提交信息,并在合并时 squash
撤销已 push 的更改
git revert
从
main
更新 branch
git merge origin/main
同一人在听到此规则后再次提出该请求执行重写
中途切换任务。 在任务 branch 上,将尚未完成的文件提交并 push,提交信息使用
wip: <what is missing>
。如果这些文件位于
main
,请先使用
git switch -c <branch>
将其移到新 branch,确保
wip:
commit 不会进入
origin/main
,并在交接说明中列出该 branch 携带的
main
本地 commit。然后在新 worktree 中开始新任务,并在交接说明中列出已搁置的工作。绝不要使用
git stash
。恢复工作时,应基于该
wip:
commit 继续。如果 hook 因未完成的工作未通过自身测试而拒绝提交,请将这些测试标记为 skipped,并在 commit message 中列明。在完成工作的 commit 中取消 skipped 状态;只要跳过且仍处于 skipped 状态的测试还存在,该 branch 就尚未准备好接受 review。
你没有做出的更改。 你的工作仅包括为当前任务创建或修改的文件。工作副本中的其他任何内容都属于他人。保持这些内容不变,不要提交、stash 或丢弃它们,并在交接说明中列出。

Red flags

危险信号

  • "It's only a feature branch" / "force-with-lease makes it safe"
  • "Only the message changes" / "the reviewer asked for exactly this"
  • "Stash is quicker" / "I'll push at the end"
  • "That failing test is theirs, not ours" / "the user's message is permission to skip the hook"
  • "Nothing may be lost, so I'll commit these other files too"
  • “这只是一个 feature branch” / “使用
    --force-with-lease
    就安全了”
  • “只改提交信息” / “reviewer 明确要求这样做”
  • “使用 stash 更快” / “我会在最后 push”
  • “那个失败的测试是他们的,不是我们的” / “用户的消息已经允许跳过 hook”
  • “不能丢失任何东西,所以我也要提交这些其他文件”