Microsoft/vscode

Git - Support for gitdir

Open

#77,215 opened on Jul 11, 2019

View on GitHub
 (19 comments) (33 reactions) (1 assignee)TypeScript (74,848 stars) (10,221 forks)batch import
feature-requestgithelp wanted

Description

I use two git repositories within project folder - one is .git and second is .git_dev. First is for project and second is to track my local config files. I used to work with second via alias git dev which stands for git --git-dir=.git_dev, but for now I explore ways to list changes within both repos in git sideview.

What I did:

  1. I create folder aside the main project folder(consider it project) and call it project_dev
  2. Initialize new repo in new folder with git init --separate-git-dir ../project/.git_dev. It creates file project_dev/.git with related line.
  3. Then create new file within project_dev folder and open it in Code. Now I'm able to view changes for both repos, but one called project_dev tracks the project_dev folder, not the project
  4. So my next step is to add setting worktree=/path/to/project in .git_dev/cofig. Now git sideview perfectly represents current changes for project_dev aside to main project.

And here I run into two issues:

  1. if I try to click on changed file in project_dev section of sideview, an error occurs with message: Unable to open 'filename (Working Tree)': Unable to read file (Error: File not found (/path/to/project_dev/filename)). like it doen't respect setting worktree at all.
  2. If I reload Code, even if I open file from project_dev folder, second repo is not shown. If I remove worktree setting, project_dev repo is shown again and I have to add worktree setting again to get changes properly.

Example repo: https://github.com/deitry/vscode-two-git-repos-issues


So, on the one hand I consider current behaviour as buggy. On the other hand, I make a request to add option to pass as many --git-dirs as I want by making it a list:

"git.gitdirs: [ ".git", ".git_dev"]

Contributor guide