From a8d23484cda2ee08a28f51210e72a5883492479a Mon Sep 17 00:00:00 2001 From: jj Date: Wed, 21 May 2025 14:41:08 +0200 Subject: [PATCH] new: Added Instructions to wipe a repository. --- know-how/git-commands.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/know-how/git-commands.md b/know-how/git-commands.md index c0c1132..c3d6a89 100644 --- a/know-how/git-commands.md +++ b/know-how/git-commands.md @@ -131,4 +131,14 @@ git branch -m main wikiMaster git push origin HEAD ``` +Wipe a whole git repository, removing all branches, tags, and history, leaving behind only a single, empty main branch. + +```bash +git checkout --orphan main && \ +git rm -rf . && \ +git commit --allow-empty -m "Initialize empty main branch" --no-verify && \ +git push origin main --force && \ +git for-each-ref --format='%(refname:short)' refs/heads/ | grep -v '^main$' | xargs -I{} git push origin --delete {} && \ +git tag -l | xargs -n 1 git push --delete origin +```