vla-data-aug-veo31-test / scripts /hf_rewrite_history_single_commit.ps1
hf-history-rewrite
Dataset snapshot (single-commit history; sanitized metadata)
83b5962
Raw
History Blame Contribute Delete
1.85 kB
# 將 Hugging Face 上資料集 repo 的 main 歷史壓成「單一 commit」並強推,
# 使網頁上不再顯示舊 commit(例如舊歷史含敏感字樣或本機路徑時)。
#
# 需求:git、git-lfs、已 hf login(或已設定可寫入該 repo 的 credential)
# 警告:會改寫遠端 main,請確認有備份需求再執行。
#
# 用法:
# cd scripts
# powershell -ExecutionPolicy Bypass -File .\hf_rewrite_history_single_commit.ps1
#
param(
[string]$RepoUrl = "https://huggingface.co/datasets/sou35/vla-data-aug-veo31-test",
[string]$Branch = "main",
[string]$WorkDir = ""
)
$ErrorActionPreference = "Stop"
if (-not $WorkDir) {
$WorkDir = Join-Path $env:TEMP "hf-rewrite-$(Get-Date -Format 'yyyyMMddHHmmss')"
}
if (Test-Path $WorkDir) {
Remove-Item $WorkDir -Recurse -Force
}
Write-Host "Cloning (depth 1) -> $WorkDir"
$env:GIT_LFS_SKIP_SMUDGE = "1"
git clone --depth 1 $RepoUrl $WorkDir
if ($LASTEXITCODE -ne 0) { throw "git clone failed" }
Push-Location $WorkDir
try {
Write-Host "Using pointer-only checkout (skip full LFS download)."
Write-Host "Creating orphan branch with current working tree..."
git checkout --orphan __sanitized_single
git add -A
git -c user.email="hf-history-rewrite@local" -c user.name="hf-history-rewrite" commit -m "Dataset snapshot (single-commit history; sanitized metadata)"
git branch -D $Branch
git branch -m $Branch
Write-Host "Force-pushing to origin $Branch (requires write access)..."
git push -f origin $Branch
if ($LASTEXITCODE -ne 0) { throw "git push -f failed" }
}
finally {
Remove-Item Env:\GIT_LFS_SKIP_SMUDGE -ErrorAction SilentlyContinue
Pop-Location
}
Write-Host "Done. Remote history on $Branch is now a single commit."
Write-Host "You may remove local clone: $WorkDir"