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



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


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

cd ${repo}

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

cd -

rm -rf ${repo}


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:



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 Join to answer
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

1,347 views 1 5
Read article

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot