Delete or remove all history, commits, and branches from a remote Git repo? -
i've read , tried lots of git command recommendations , discussion, going on over several days now. appears there no simple, comprehensive way make remote git repo empty -- no branches, no refs, no objects, no files, no nothing.
yes, i recognize 1 delete , recreate repo -- if 1 had kind of permissions on origin (which don't), not point. how done? combination of git commands this, leaving repo in virgin state ready receive whatever wish push it, , with no size (or minimal size of virgin repo)?
please don't tell me shouldn't done, or have inform users, etc. know that. i want start fresh.
you might want try pushing empty local repo --mirror
flag (emphasis mine):
--mirror
instead of naming each ref push, specifies refs under refs/ (which includes not limited
refs/heads/
,refs/remotes/
, ,refs/tags/
) mirrored remote repository. newly created local refs pushed remote end, locally updated refs force updated on remote end, , deleted refs removed remote end. default if configuration optionremote.<remote>.mirror
set.
if repo on github, you'll error if master
set default branch when trying push:
$ mkdir practice; cd practice; $ git init; git remote add origin git@github.com:user/practice.git; $ git push origin --mirror remote: error: refusing delete current branch: refs/heads/master git@github.com:user/practice.git ! [remote rejected] master (deletion of current branch prohibited) error: failed push refs 'git@github.com:user/practice.git'
i got around making initial commit, pushing.
obligatory warning: will, of course, wipe out of history , commits in remote repo—all references, branches, tags, etc. make sure want do. of course, can make backup clone of remote repo before doing this, in case want keep around whatever reason.
also note none of commits deleted right away. they'll become dangling commits, meaning they're not reachable branch. they'll garbage collected git repos, if have access remote repo, can manually start garbage collection git gc
.
Comments
Post a Comment