How to Duplicate a GitHub Repository
With Full Commit History

A reusable step-by-step guide to copy one of your own repos as a starting point for a new project — preserving branches, tags, and every commit.

Prerequisites

  • Both the original and new repositories are under your own GitHub account (or you have write access to both).
  • The new repository already exists on GitHub and is completely empty — no README, no .gitignore, no license. Create it at github.com/new and uncheck all “Initialize this repository” options.

Step-by-Step Instructions

Run these commands in your terminal:

# 1. Navigate to your preferred local folder (optional but recommended)
cd ~/Documents/GitHub   # adjust path as needed

# 2. Create a temporary bare mirror of the original repo
git clone --mirror https://github.com/YOUR-USERNAME/original-repo-name.git

# 3. Enter the mirrored folder
cd original-repo-name.git

# 4. Push everything (history, branches, tags) to the new empty repo
git push --mirror https://github.com/YOUR-USERNAME/new-repo-name.git

# 5. (Optional) Clean up the temporary mirror
cd ..
rm -rf original-repo-name.git

# 6. Clone the new repo normally to start working
git clone https://github.com/YOUR-USERNAME/new-repo-name.git
cd new-repo-name

# You're ready to make changes!

Real-World Example

cd ~/Documents/GitHub

git clone --mirror https://github.com/shadstoneofficial/app-evilbuyers-com.git
cd app-evilbuyers-com.git
git push --mirror https://github.com/shadstoneofficial/dailyschools-app.git

cd ..
rm -rf app-evilbuyers-com.git   # cleanup

git clone https://github.com/shadstoneofficial/dailyschools-app.git
cd dailyschools-app

Common Issues & Fixes

RPC failed; HTTP 400 error

Increase Git’s HTTP buffer size and retry the push:

git config --global http.postBuffer 524288000

Prefer SSH for larger repos

Use SSH URLs instead of HTTPS for better reliability:

  • git@github.com:YOUR-USERNAME/original-repo-name.git
  • git@github.com:YOUR-USERNAME/new-repo-name.git

When NOT to Use This Method

  • If you don’t need the commit history — just create a new repo and copy files manually.
  • If the repo is very large and you only want the latest code — a regular clone + new remote is simpler.

Related

Once your repo is set up with SSH URLs, clone it on a remote VPS to run Codex and Claude Code agents without overloading your Mac.

That’s it! You now have an exact duplicate with full history, ready for your next project.