git 如何复制git存储库?(不分叉)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6613166/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to duplicate a git repository? (without forking)
提问by cowboybebop
I have two repositories, and I need to copy whole of one onto the other empty one which has different access levels from the first one. The copy and the mother repository should not be linked together.
我有两个存储库,我需要将整个存储库复制到另一个与第一个具有不同访问级别的空存储库上。副本和母存储库不应链接在一起。
I am new to git and it would be awesome if someone could help me with this.
我是 git 的新手,如果有人可以帮助我,那就太棒了。
回答by Larry K
See https://help.github.com/articles/duplicating-a-repository
请参阅https://help.github.com/articles/duplicating-a-repository
Short version:
精简版:
In order to make an exact duplicate, you need to perform both a bare-clone and a mirror-push:
为了精确复制,您需要执行裸克隆和镜像推送:
mkdir foo; cd foo
# move to a scratch dir
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
NOTE: the above will work fine with any remote git repo, the instructions are not specific to github
注意:上述内容适用于任何远程 git repo,说明并非特定于 github
The above creates a new remote copy of the repo. Then clone it down to your working machine.
以上创建了一个新的 repo 远程副本。然后将其克隆到您的工作机器上。
回答by Quanlong
回答by Mateus Gondim
If you are copying to GitHub, you may use the GitHub Importerto do that for you. The original repo can even be from other version control systems.
如果您要复制到 GitHub,则可以使用GitHub 导入器为您完成此操作。原始 repo 甚至可以来自其他版本控制系统。
回答by tim
If you just want to create a new repository using all or most of the files from an existing one (i.e., as a kind of template), I find the easiest approach is to make a new repo with the desired name etc, clone it to your desktop, then just add the files and folders you want in it.
如果您只想使用现有存储库中的全部或大部分文件(即作为一种模板)创建一个新存储库,我发现最简单的方法是使用所需名称等创建一个新存储库,将其克隆到您的桌面,然后只需在其中添加您想要的文件和文件夹。
You don't get all the history etc, but you probably don't want that in this case.
你没有得到所有的历史等,但在这种情况下你可能不想要。
回答by Kundan roy
Open Terminal.
打开终端。
Create a bare clone of the repository.
创建存储库的裸克隆。
git clone --bare https://github.com/exampleuser/old-repository.git
git clone --bare https://github.com/exampleuser/old-repository.git
Mirror-push to the new repository.
cd old-repository.git
cd old-repository.git
git push --mirror https://github.com/exampleuser/new-repository.git
git push --mirror https://github.com/exampleuser/new-repository.git