Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reverts #41335
file: tools/github_nuke_and_wipe.sh
Usage:
1) Read and understand. Backup first.
2) Set env: export GITHUB_TOKEN="ghp_xxx"; export OWNER="your-username-or-org"; export REPO="repo-name"
3) Run python3 github_nuke.py # to remove GitHub objects and delete repo
4) Optionally run this script to purge local history and force-push a single clean commit:
NOTE: This bash helper performs a local destructive rewrite and force-push.
set -euo pipefail
if [ -z "${GITHUB_TOKEN:-}" ] || [ -z "${OWNER:-}" ] || [ -z "${REPO:-}" ]; then
echo "Please set GITHUB_TOKEN, OWNER and REPO environment variables."
echo "Example: export GITHUB_TOKEN=ghp_xxx; export OWNER=me; export REPO=myrepo"
exit 1
fi
REMOTE_URL="https://${GITHUB_TOKEN}@github.com/${OWNER}/${REPO}.git"
echo "=== Local destructive workflow start ==="
echo "Cloning mirror (bare)..."
git clone --mirror "${REMOTE_URL}" "${REPO}.git"
cd "${REPO}.git"
echo "Creating an empty orphan repository to replace history..."
Create a temporary bare repo that will become the new history
git checkout --orphan tmp-clean || true
Remove all files from index (we're in a bare clone, use worktree to rebuild)
git --work-tree=/tmp/tmp_worktree init /tmp/tmp_worktree
rm -rf /tmp/tmp_worktree/*
add a minimal README
echo "# Repository reinitialized" >/tmp/tmp_worktree/README.md
git --git-dir=. --work-tree=/tmp/tmp_worktree add README.md
git --git-dir=. --work-tree=/tmp/tmp_worktree commit -m "Reinitialized repository - all prior history removed"
Now replace refs with new single commit
NEW_HEAD=$(git rev-parse HEAD)
echo "New root commit: $NEW_HEAD"
echo "Force pushing rewritten history to remote (all branches and tags will be overwritten)..."
git push --mirror "${REMOTE_URL}" --force
echo "Cleaning local mirror..."
cd ..
rm -rf "${REPO}.git" /tmp/tmp_worktree
echo "=== Local destructive workflow completed ==="