I want to copy all my repo A to repo B with all history details. for which I am following below commands
git clone --mirror old-repo-url new-repo
cd new-repo
git remote remove origin
git remote add origin new-repo-url
git push --all
I get this below error when I try to push git push --all command
! [rejected] main -> main (fetch first)
error: failed to push some refs to 'https://git.repoB'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
When I try to run git pull command, system says "fatal: this operation must be run in a work tree". Can anyone tell how to resolve this issue?
Reference - https://itnext.io/git-repository-transfer-keeping-all-history-670fe04cd5e4