一键导入
git-rev-parse-multi-ref-short
Don't combine `git rev-parse --short` with multiple refs; it demands a single revision.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Don't combine `git rev-parse --short` with multiple refs; it demands a single revision.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
A TRefCountPtr/TSharedPtr member in a UE class needs the pointee's full definition, not a forward decl.
When WSL's mirrored networking fails and falls back to "None", plus /etc/wsl.conf has generateResolvConf=false, the distro has no DNS; fix both layers.
When a Windows shell (PowerShell/cmd) feeds a bash script into WSL, CRLF line endings can corrupt the first shell builtin; force LF or pipe via a temp file.
Before "fixing" a recurring error, check git log to see if it was already fixed upstream — the working tree may just be stale.
Always add a space after URL brackets in Markdown to prevent 404 errors with special characters.
Plan a Python 3 modernization sweep (f-strings, super(), type hints) as a series of mechanical PRs, not one mega-PR.
| name | git-rev-parse-multi-ref-short |
| description | Don't combine `git rev-parse --short` with multiple refs; it demands a single revision. |
| tags | ["git","cli","pitfall"] |
git rev-parse --short rejects multiple refsYou want to verify that several branches / tags / commits all point
to the same object (e.g. right after cutting a release branch and
tag from the same master HEAD) and you reach for the one-liner
git rev-parse --short v2.0.1 2.x v3 master
…only to get fatal: Needed a single revision. Same if you drop the
shortening length (--short=7 …).
git rev-parse --short (or --short=<n>) is documented as an
abbreviation flag: it takes exactly one object and prints its
shortened hash. Passing more than one ref flips git into a different
code path that aborts with:
fatal: Needed a single revision
exit status 128. This is independent of whether the refs resolve to
the same commit — git rejects the invocation before resolving.
Without --short, the very same argument list works fine:
$ git rev-parse v2.0.1 2.x v3 master
84f89b4e30ebbf44caef67103b546f4990e94c83
84f89b4e30ebbf44caef67103b546f4990e94c83
84f89b4e30ebbf44caef67103b546f4990e94c83
84f89b4e30ebbf44caef67103b546f4990e94c83
The trap is that the error message (Needed a single revision) reads
like "you gave me zero" or "I couldn't parse one", not "you gave
me too many combined with --short". Agents often respond by
tweaking the refs rather than dropping the flag.
Pick the shape that matches your intent:
| Goal | Recipe |
|---|---|
| Multiple refs, full SHA | git rev-parse ref1 ref2 ref3 |
| Multiple refs, short SHA, one line | for r in ref1 ref2 ref3; do git rev-parse --short "$r"; done |
| Multiple refs, short SHA, labelled | for r in ref1 ref2 ref3; do echo "$r -> $(git rev-parse --short "$r")"; done |
| Single ref, short SHA | git rev-parse --short ref1 (the canonical use) |
The loop variants also produce clearer output when you want to see which SHA belongs to which ref — which is usually the real goal when you reach for this command.
Verifying a freshly cut LTS branch + release tag + next-major branch
all pivot on the same master commit:
# WRONG — fatal: Needed a single revision
git rev-parse --short v2.0.1 2.x v3 master
# RIGHT — labelled, short SHA each
for r in v2.0.1 2.x v3 master; do
echo "$r -> $(git rev-parse --short "$r")"
done
# v2.0.1 -> 84f89b4
# 2.x -> 84f89b4
# v3 -> 84f89b4
# master -> 84f89b4
# Also RIGHT — full SHA, one per line, order matches input
git rev-parse v2.0.1 2.x v3 master
git rev-parse --verify --short ref still only takes one ref.
--verify doesn't loosen the single-revision constraint.git log --oneline -1 ref1 ref2 is not an equivalent workaround:
git log with multiple positional refs means "history reachable
from any of them", not "show each one".git show-ref output to "solve" this —
it mixes local/remote refs and invites grep-of-output bugs. The
loop is shorter and safer.--short because it's a common
flag; double-check when you're batching refs.git help rev-parse — --short[=<length>] section.