简体   繁体   中英

Github - use one repo as basis for another, preserving branches and history

I'd like to move over a repo, with all its history and branches, to a fresh repo. I've been able to find ways to use a single branch as a basis for a new repo ( git workflow - using one repo as the basis for another ), but I can't figure out how I'd preserve all branches (and their histories, ideally). Is there a way to do this? or possibly a clever workaround so I don't lose my work on non-master branches?

您可以简单地将存储库分叉到Github上,该存储库将对其进行完整复制,并将该副本链接到原始存储库,以生成对其的请求。

Clone a fresh copy of your repo, using the --mirror flag:

$ git clone --mirror git://example.com/some-big-repo.git

This is a bare repo, which means your normal files won't be visible, but it is a full copy of the Git database of your repository, including all branches. Once cloned, set the origin to be your new repo, and push:

$ git remote set-url origin git://new.com/some-big-repo.git
$ git push

All branches will be transferred, and this method will work for any Git host, not just GitHub.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM