0

I have 2 repositories in git....REPO1 and REPO 2. I have cloned REPO1 and all works fine. I have added 1 additional folder inside the project(REPO1) which I need to checkout/track in one branch inside REPO2. How do I do that.

I have tried git remote -v and git remote set-url origin https://github.com/user/repo2.git as per: How to change the URI (URL) for a remote Git repository?

but when I do a git branch from inside the folder, it still shows the branches in REPO1 and not REPO2.

Yogesh
  • 246
  • 1
  • 4
  • 20
  • Does this answer your question? [Maintain git repo inside another git repo](https://stackoverflow.com/questions/4659549/maintain-git-repo-inside-another-git-repo) – Orace Aug 17 '21 at 15:11

1 Answers1

1

What you are trying to do is a submodule.

Remove the folder (git will create it) and try:

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

See the documentation for more information.

Orace
  • 7,822
  • 30
  • 45
  • Thanks Orace.. that works. But can I do it the other way round. I mean create a folder in the project and have its tracking set to REPO2. While the remaining part or the project still track to REPO1. – Yogesh Aug 17 '21 at 15:17