Skip to content

duck duck goose #41339

@jerod0668-create

Description

@jerod0668-create

Code of Conduct

What article on docs.github.com is affected?

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 ==="

What part(s) of the article would you like to see updated?

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 ==="

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    contentThis issue or pull request belongs to the Docs Content teaminvalidThis issue/PR is invalid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions