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 +```