How to Duplicate a Git Repo and Copy Git History

Summary

$ git clone --bare "https://github.com/username/git-repo-name"
$ git push --mirror https://github.com/exampleuser/new-repository.git
$ git clone 'https://github.com/omartheman/Omars-New-Project.git'

Step 1: Create a blank remote repo (our target repo)

Step 2: Create a bare clone of the repo

Info about a bare git repo, for those who want to know

Step 3: Push a mirror of the bare clone to the remote repo

$ cd old-repository.git
$ git push --mirror https://github.com/exampleuser/new-repository.git

Step 4: Clone new remote repo into local machine

$ cd 'our-destination-parent-folder'
$ git clone 'https://github.com/omartheman/Omars-New-Project.git'

Step 5 (optional): Add new repo to GitHub Desktop

That’s it!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store