Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect git subfolder in Visual studio code

I have a folder where the root folder is not git repository but the underlying src/ folder is. So for example I have this

 ~/workspace/some_project_folder <-- not a git repository
 ~/workspace/some_project_folder/src <-- git repository
 ~/workspace/some_project_folder/some_other_folder <-- not a git repository
 ~/workspace/some_project_folder/transient_data <-- not a git repository

(Note this structure is by all means not good but this what I have inherited. I will change this in the future, I just want a workaround for the moment)

I was searching for option to specify that my main git folder is under src but could not find any such option.

Is there a way to to recognise subfolders in Visual Studio Code? Currently sticking with the cmd git.

like image 485
eenagy Avatar asked Nov 28 '16 07:11

eenagy


People also ask

How do I open multiple folders in VS Code?

Drag and drop# You can even select and drag multiple folders. Note: Dropping a single folder into the editor region of VS Code will still open the folder in single folder mode. If you drag and drop multiple folders into the editor region, a new multi-root workspace will be created.


Video Answer


1 Answers

Unfortunately there is no support for it in VSCode in ver. 1.15.1 (it's added in 1.16 though, see nr 3).

This is related to the following issue: https://github.com/Microsoft/vscode/issues/396 (search for git)

You have to set the git project as a main one in VSCode to make git working properly. It means that probably you need to have two VSCode windows to be opened at the same time:

  • the first one with ~/workspace/some_project_folder for general overview,

  • the second one with ~/workspace/some_project_folder/src for seeing and handling git changes.

1) There is an interesting plugin which can make life a bit easier:

Git Project Manager: https://marketplace.visualstudio.com/items?itemName=felipecaputo.git-project-manager

It can scan your main folder for git repositories in subfolders and you can quickly select the git repo to be opened in a separate window using command GPM: Open Git Project from SubFolder.

2) On the other hand in there is a plan to support multiple folders in one workspace in ver. 1.6 using command: Workspaces: Add Folder to Workspace..., so you can add the src folder separately and it will be visible as a git repo.

However currently this option is only visible in 'insiders' version, which you can download from:

https://code.visualstudio.com/insiders

Edit:

3) It seems that ver. 1.6 supports git subfolders finally.

like image 144
Adam Szlachta Avatar answered Sep 28 '22 02:09

Adam Szlachta