【问题标题】:Tracking a pushing to a new repository in git在 git 中跟踪推送到新存储库
【发布时间】:2026-02-05 19:40:01
【问题描述】:

我在 git....REPO1 和 REPO 2 中有 2 个存储库。我已经克隆了 REPO1,一切正常。我在项目(REPO1)中添加了 1 个额外的文件夹,我需要在 REPO2 的一个分支中签出/跟踪。我该怎么做。

我已经尝试过 git remote -v 和 git remote set-url origin https://github.com/user/repo2.gitHow to change the URI (URL) for a remote Git repository?

但是当我从文件夹内执行 git 分支时,它仍然显示 REPO1 中的分支,而不是 REPO2。

【问题讨论】:

标签: git gitlab bitbucket


【解决方案1】:

你想要做的是submodule

删除文件夹(git会创建它)并尝试:

git submodule add https://url.of/REPO2

更多信息请参见the documentation

【讨论】:

  • 感谢 Orace .. 有效。但是我可以反过来做吗?我的意思是在项目中创建一个文件夹并将其跟踪设置为 REPO2。而其余部分或项目仍跟踪到 REPO1。