how to sync a repo mirror to a new upstream repo

2019-07-18 07:54发布

问题:

I have a repo mirror server (myrepo) that was originally created to mirror and sync with a remote (repoA). That is, I used something like the following to create it.

cd myrepo
repo init -u git://repoA-server/manifest.git --mirror
repo sync

...then I modified manifest file's fetch line to use myrepo server so users can clone from myrepo mirror

So now repoA is gone and doesn't exist anymore. It has been replaced with a new repoB server at a different URL which has modified some of the branches and uses a new manifest file for those branches.

How can I resync my myrepo mirror with this new repoB? I don't want to blow away my myrepo and just create a new mirror. I want to retain its history and just update some of the branches to now track from repoB, and use the new manifest file (which I will again modify to fetch projects from myrepo).

I'm not sure how to go about doing this? I'm wondering if I can simply make some change in myrepo and then just run 'repo sync' to have it sync up with new mirror (i.e. do a fetch/merge for updates branches)? Or do I have to clone myrepo then do something like add repoB as a remote, create tracking branches, fetch/merge myself, and try to push that up to myrepo?

回答1:

go ahead and change the urls/paths in the config file:

.git/config

That would be the fastest way. Although you could address each branch setup with commands.

Also, please note that you would not lose any history if you were to reclone if they are in sync. You would lose your reflog and rr-cache among other things.

hope this helps.

Adam