MIgrating Git Repositories

Hi there,

does anyone know if there is a possibility to migrate git repositories from an existing server in a batch?

1 answer

current_url="ssh://git@somehost/"

new_url="http://user:pass@somehost/gitsomething/"

for repo in one.git two.git three.git

do

git clone --mirror ${current_url}${repo}

cd ${repo}

git push --mirror ${new_url}${repo}

cd -

rm -rf ${repo}

done

That will replicate the contents from one server to the other.

...except there is no --mirror in git pull. Here is the answer on how to get all changes from one repo:

http://stackoverflow.com/questions/2213689/opposite-of-git-push-mirror-how-do-i-get-my-repo-back

TL;DR:

instead of 'git pull --mirror' use

git fetch ${current_url}${repo} +refs/heads/*:refs/heads/*

Thanks to your post I saw my mistype...

It was supposed to be clone instead of pull.

Here is my implementation (it makes a bare repo btw)
git clone --mirror $fromrepo ${BASEDIR}/${tmpname}

I then push it up into the other server
git push --mirror --force ${torepo}

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jun 12, 2018 in Bitbucket

Do you use any Atlassian products for your personal projects?

After spinning my wheels trying to get organized enough to write a book for National Novel Writing Month (NaNoWriMo) I took my affinity for Atlassian products from my work life and decided to tr...

188 views 20 8
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you