DEV Community

Ismail PE
Ismail PE

Posted on Edited on

Duplicating a github repo with history

Are you moving your codebase into a different versioning system? It's so easy to duplicate a github repository including every commits and branches.

1) Create a new repo in github using UI/command as usual. This will be the target repo where duplicate of source repo to be pasted.

2) Open a command prompt and Clone the source/existing repo using the command:

git clone --bare https://sourceRepoURL

A new folder will be created containing some files from source repo.

3) Move to that folder:
cd sourceRepoFolder

4) Push these files into the target repo using command:
git push --mirror https://targetRepoURL

That's it. Thank you.

Top comments (8)

Collapse
 
ofekp profile image
Ofek •

Thank you!

Collapse
 
ederfdias profile image
Eder Ferreira Dias •

Awesome,
Thanks!

Collapse
 
larrynoriega profile image
Larry Noriega •

Mate, the very best one instructions out there innit!

Collapse
 
daattali profile image
Dean Attali •

I created an account on this website just to say: THANK YOU! This is so much easier than the dozens of stackoverflow and blog post solutions I saw. This works and is so simple!

Collapse
 
mghdeveloppers profile image
MGH Developpers •

Thank you !!
you just saved my day__

Collapse
 
ammarhasan76 profile image
Ammar •

Thank you so much!

Collapse
 
nifazzz10 profile image
Nifaz •

how to git pull the changes

Collapse
 
ismailpe profile image
Ismail PE •

It seems you have a different requirement and need to fork the repo instead. Then you can pull changes from the source repo always and keep your child repo with your own modifications.