You might want to try an empty local repo with the --mirror flag (my selection):
--mirror
Instead of calling each ref for push, it indicates that all refs in refs / (which includes but is not limited to refs/heads/ , refs/remotes/ and refs/tags/ ) are mirrored to the remote repository. Newly created local links will be moved to the remote end, locally updated links will be forced to be updated at the remote end, and deleted links will be deleted from the remote end . This is the default value if the remote.<remote>.mirror configuration parameter is remote.<remote>.mirror .
If your repo is on GitHub, you will get this error if the default branch is set when you try to press master :
$ mkdir practice; cd practice; $ git init; git remote add origin git@github.com:user/practice.git; $ git push origin --mirror remote: error: refusing to delete the current branch: refs/heads/master To git@github.com:user/practice.git ! [remote rejected] master (deletion of the current branch prohibited) error: failed to push some refs to 'git@github.com:user/practice.git'
I circumvented this by making an initial commit, and then clicking.
Mandatory warning : this, of course, will completely destroy your entire history and commit your remote repo: all links, all branches, all tags, etc. Make sure that this is actually what you want to do. Of course, you can always make a backup clone of your remote repo before doing this if you want to keep it for any reason.
Also note that none of the commits will be deleted immediately. They will just become chatty commits, which means that they are inaccessible from the branch. In the end, they will get garbage collected by Git repositories, but if you have access to the remote repo, you can manually start garbage collection using git gc .
user456814 Aug 07 '13 at 20:27 2013-08-07 20:27
source share