How to move git repository without losing history in 5 minutes

This quick TIP will guide us to move a repository to the new one.

1/ Checkout everything from the old repository

git clone --mirror <url to OLD repo>

2/ Push everything to the new repository

git push --mirror <url to NEW repo>

3/ Update remote origin

Remove old remote origin

git remote rm origin

Replace remote origin by new repository

git remote add origin <url to NEW repo>

Done, enjoy your new repository.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.