How to copy a repository into a new (not fork) repo #190416
-
Select Topic AreaQuestion BodyI have an old_repo that I want to use as a source to copy into a new_repo. From https://docs.github.com/en/repositories/creating-and-managing-repositories/duplicating-a-repository I created the NEW-REPOTORY in github, then when I am doing the final push, I get: then from https://www.bstefanski.com/blog/how-to-resolve-git-fatal-the-remote-end-hung-up-unexpectedly, I increased the buffer: and I still get any ideas what is the problem? |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 1 reply
-
|
Do it step by step from a terminal:
git clone --mirror https://github.com/EXAMPLE-USER/OLD-REPOSITORY.git
cd OLD-REPOSITORY.git
git remote set-url origin https://github.com/EXAMPLE-USER/NEW-REPOSITORY.git
git push --mirror OR You can also send it as one block so they can copy everything at once: git clone --mirror https://github.com/EXAMPLE-USER/OLD-REPOSITORY.git |
Beta Was this translation helpful? Give feedback.
-
|
Practical fixes |
Beta Was this translation helpful? Give feedback.
-
1. Clone the source repository as a mirrorgit clone --mirror https://github.com/EXAMPLE-USER/OLD-REPOSITORY.git 2. Go into the mirrored repositorycd OLD-REPOSITORY.git 3. Point origin to the new repositorygit remote set-url origin https://github.com/EXAMPLE-USER/NEW-REPOSITORY.git 4. Push everything to the new repositorygit push --mirror Or as one block: |
Beta Was this translation helpful? Give feedback.
-
GitHub Repo Copy Problem & FixWhat is the Problem?You want to copy an old GitHub repo into a brand new repo (not as a fork). But you get this error: error: RPC failed; curl 18 Transferred a partial file
send-pack: unexpected disconnect while reading sideband packet
fatal: the remote end hung up unexpectedly
Your repo is big (~350 MB with 326k objects). Even after setting `http.postBuffer 2147483648` the push still fails.Simple Solution (Works Most Times)Step 1: Make New Empty Repo on GitHub
Step 2: Run These Commands# Clone as mirror
git clone --mirror https://github.com/YOUR-USERNAME/OLD-REPO.git
# Go inside
cd OLD-REPO.git
# Point to new repo
git remote set-url origin https://github.com/YOUR-USERNAME/NEW-REPO.git
# Push everything
git push --mirrorReplace Quick Fix for the RPC ErrorBefore pushing, run this: git config http.postBuffer 524288000Or try SSH (more stable): git remote set-url origin git@github.com:YOUR-USERNAME/NEW-REPO.git
git push --mirrorDone!Refresh the new repo on GitHub. All files, history and branches are now copied exactly. Just copy the whole thing above and save as |
Beta Was this translation helpful? Give feedback.
-
|
Hello @edgarbc The Solution: Switch to SSH with Ed25519
1. Generate the Ed25519 Key Pair: Ed25519 is the most modern and efficient public-key algorithm available in Git today.
When prompted to "Enter a file in which to save the key," just press Enter to accept the default. 2. Add Key to the SSH Agent 3. Add the Public Key to GitHub : Copy the contents of your public key to your clipboard
Action: Go to your GitHub SSH Settings, click New SSH Key, and paste the content. 4. Update your Remote and Mirror Push
Why this fixes the issue:
|
Beta Was this translation helpful? Give feedback.
-
|
Thanks for all the suggestions and help! At the end I found the problem. When you create the new repo, you need to make sure it is completely empty (no README, no branches, etc). What I did was to delete the new repo and start from scratch. I had used copilot to initiate the previous new repo giving copilot instructions to do the copy, it created a PR... After creating a empty new repo from scratch, the approach that I described at the top works just fine. 😁 |
Beta Was this translation helpful? Give feedback.
GitHub Repo Copy Problem & Fix
What is the Problem?
You want to copy an old GitHub repo into a brand new repo (not as a fork).
You followed the official guide:
git clone --bare OLD-REPOthengit push --mirror NEW-REPOBut you get this error:
Simple Solution (Works Most Times)
Step 1: Make New Empty Repo on GitHub
NEW-REPO(keep it empty — no README).Step 2: Run These Commands
# Clone as mirror git clone --m…