Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

MIgrating Git Repositories

Onur Onur May 9, 2012

Hi there,

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

1 answer

0 votes
roy_lyons
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 9, 2012

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.

Aleksey Maksimov July 22, 2013

...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/*

roy_lyons
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 22, 2013

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
TAGS
AUG Leaders

Atlassian Community Events