$ git clone --bare https://github.com/exampleuser/old-repository.git
# Make a bare clone of the repository
$ cd old-repository.git
$ git push --mirror https://github.com/exampleuser/new-repository.git
# Mirror-push to the new repository
$ cd ..
$ rm -rf old-repository.git
# Remove our temporary local repository
如果希望在另一个位置镜像存储库,包括从原始存储库获取更新,可以克隆一个镜像并定期推送更改。
$ git clone --mirror https://github.com/exampleuser/repository-to-mirror.git
# Make a bare mirrored clone of the repository
$ cd repository-to-mirror.git
$ git remote set-url --push origin https://github.com/exampleuser/mirrored
# Set the push location to your mirror
git clone --bare https://github.com/exampleuser/public-repo.git
cd public-repo.git
git push --mirror https://github.com/yourname/private-repo.git
cd ..
rm -rf public-repo.git
克隆私有回购,这样你就可以对它进行操作:
git clone https://github.com/yourname/private-repo.git
cd private-repo
make some changes
git commit
git push origin master
从公共回购中获取新的热点:
cd private-repo
git remote add public https://github.com/exampleuser/public-repo.git
git pull public master # Creates a merge commit
git push origin master