Git 克隆远程仓库到另一个远程仓库
Git clone remote repo into another remote repo
将 git 存储库从远程服务器克隆到本地计算机以标准方式很容易完成,但我需要将一个远程存储库克隆到另一个远程存储库中,这可能吗?
P.S。我想出这个问题是因为我不能在 GitHub 上分叉我自己的项目来创建子项目,我只能分叉其他用户的项目。这是关于克隆以从父项目创建整个子项目,而不仅仅是子模块。
Cloning git repo from remote server to local computer is rather easily done the standard way, but I need to clone a remote repo into another remote repo, is it possible?
在 git 中,您不能在另一个 git 文件夹中包含 .git
文件夹
你能做什么?
- 克隆原始存储库
- 添加新遥控器
git remote add <origin2> <url2>
- 在单个存储库中使用来自两个存储库的代码
现在您可以拉取和合并 2 个远程的分支,并将它们的代码放在一个存储库中。
正如您在下图中看到的,您将拥有 2 个构建您的大存储库的存储库。
# clone first repository
git clone <repo1>
# add remote
git remote add <remote2> <url2>
# display the list of all the remotes
git remote -v
注意:<remote2>
不能是现有的远程名称。
将 git 存储库从远程服务器克隆到本地计算机以标准方式很容易完成,但我需要将一个远程存储库克隆到另一个远程存储库中,这可能吗?
P.S。我想出这个问题是因为我不能在 GitHub 上分叉我自己的项目来创建子项目,我只能分叉其他用户的项目。这是关于克隆以从父项目创建整个子项目,而不仅仅是子模块。
Cloning git repo from remote server to local computer is rather easily done the standard way, but I need to clone a remote repo into another remote repo, is it possible?
在 git 中,您不能在另一个 git 文件夹中包含 .git
文件夹
你能做什么?
- 克隆原始存储库
- 添加新遥控器
git remote add <origin2> <url2>
- 在单个存储库中使用来自两个存储库的代码
现在您可以拉取和合并 2 个远程的分支,并将它们的代码放在一个存储库中。
正如您在下图中看到的,您将拥有 2 个构建您的大存储库的存储库。
# clone first repository
git clone <repo1>
# add remote
git remote add <remote2> <url2>
# display the list of all the remotes
git remote -v
注意:<remote2>
不能是现有的远程名称。