I want to mirror a git repo 'main'. The mirrored repo just mirrors the main repo on different provider. that means when changes happens on the main the mirror repo on the new provider reflect the changes.
I tried
$ git clone --mirror git@example.com/old-upstream-repository.git
$ cd old-upstream-repository.git
$ ls
HEAD branches config description hooks info objects packed-refs refs
$ git push --mirror git@example.com/new-location.git
but when I run the push
command I get
remote: error: object 0a3: hasDotgit: contains '.git'
remote: fatal: fsck error in packed object
error: remote unpack failed: index-pack abnormal exit
To git@example.com/new-location.git
! [remote rejected] develop -> develop (unpacker error)
! [remote rejected] feature/2321-new-edit-for-all -> feature/2321-new-edit-for-all (unpacker error)
error: failed to push some refs to 'git@example.com/new-location.git'
I assume I am pushing a bare repo since I also get the message
fatal: this operation must be run in a work tree