git - 如何复制一个 git 仓库? (没有 fork )

标签 git github

我有两个存储库,我需要将整个存储库复制到另一个空的存储库,该存储库的访问级别与第一个存储库不同。副本和母存储库不应链接在一起。

我是 git 的新手,如果有人能帮助我,那就太棒了。

最佳答案

参见 https://help.github.com/articles/duplicating-a-repository

简短版:

为了进行精确复制,您需要同时执行裸克隆和镜像推送:

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

注意:以上内容适用于任何远程 git 仓库,说明并不特定于 github

上面创建了一个新的 repo 远程副本。然后将其克隆到您的工作机器上。

关于git - 如何复制一个 git 仓库? (没有 fork ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6613166/

相关文章:

git - 无法登录 SourceTree

git - Visual Studio Code 总是要求提供 Git 凭据

git - 如何在 git push 上修复 "cannot be resolved to branch"?

javascript - 我无法使用带有 react.js 的 redux 从 github api 获得响应

python - 如何在 Github 操作中访问矩阵变量

git - 如果 '/' 是存储库的根目录,为什么 git 会中断?

git - 当你有文件时如何克隆 Bitbucket 存储库?

git - 如何使用 TortoiseGit 在本地 checkout fork 的 pull 请求?

github - 使用 AWS CodePipeline 在 Jenkins 中构建多个 Gradle 项目

jenkins - 如何将 SonarCloud 与 GitHub 和 Jenkins 集成