在 git 中跟踪对新存储库的推送

Tracking a pushing to a new repository in git

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

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

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

您要做的是 submodule

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

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

有关详细信息,请参阅 the documentation