私は今朝、これに対する正しい答えに気づきました:
.git/refs の下のすべては参照であるため、プルーニングされませんが、refs/heads のみがブランチであり、refs/tags はタグなどです。したがって、ブランチを「アーカイブ」refs ディレクトリにシャントするだけです。本当に強引な方法はmkdir -p .git/refs/archive/heads; mv .git/refs{,/archive}/heads/master
、そのブランチの以前にアーカイブされたバージョンを踏みにじることです。より完全なバージョンは次のとおりです。
#!/bin/sh
# archive a branch, by committing it to .git/refs/archive/heads/
# to unarchive the branch, say 'git branch mybranch archive/heads/mybranch~'
# ---- NOIICE the parent link in the branch command above ----------------/
# any second parent of the archive ref is the previous archive header commit
getopts x x && set -x -v && shift
while test $# -ne 0; do
branch="refs/heads/$1"
archive="refs/archive/heads/$1"
git rev-parse -q --verify "$branch" >&- \
|| { echo >&2 archive-branch ignored nonexistent branch: $1; shift; continue; }
previously=`git rev-parse -q --verify "$archive"`
git mktree </dev/null | xargs git commit-tree \
-p "`git rev-parse "$branch"`" \
${previously:+ -p $previously} \
-m "Parent is the archived tip of branch '$1'" \
${previously:+ -m 'Second parent is the previous commit like this one.'} \
> "`git rev-parse --git-dir`/$archive"
rm "`git rev-parse --git-dir`/$branch"
shift
done