0

I originally created a git repository in main directory. Later on, I created another repository in a child directory. Now if I open child directory codes in VS Code, it will use the .git in child directory even I open it in parent directory: VScode ./child.

The trick I use is to rename .git in child directory so VS code will use the parent directory repository. I am curious if there is a setting in VS Code so I can pick the repository I'd like to use?

HHung
  • 49
  • 5

1 Answers1

0

I am not quite sure how to understand your question. What do you mean by "can I pick the repo"? Yes, of course you can. You can have as many repos as you want parallely. However, there are two things I think of when reading your description...

  1. If you wish to restructure your local repository location or hierarchy, you can - at any time - just delete the repository and clone the central one again (I suggest using VS Code by Ctrl + Shift + P and Git: Clone). By doing so, you can choose the repository location. If your Git project is not too big, this process should take only a few seconds or minutes.

  2. If you want to keep your current repository situation and just open or close them in VS Code to make it simpler and get an overview, you can always go on file > open folder or file > open workspace and add them in the left-handside menuebar to VS Code.

It all depends on wether you have too repos with the same code or not. The first of those options doesn't make sense in my opinion.

  • Sorry for not being clear enough. I had a repo in parent directory then I created another in a child directory. So they are not parallel. I found out if I open the parent directory VSCode ./. It will use the .git in the parent directory. On the other hand, if I do VSCode ./child, it uses .git in the child directory. I think this is expected. Issue resolved now. Thanks. – HHung Aug 09 '20 at 18:37