question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Git: Support for gitdir

See original GitHub issue

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"]

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:19
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

12reactions
texastolandcommented, Apr 19, 2020

Workaround for anyone else arriving from #80946:

alias dotfiles="GIT_WORK_TREE=~ GIT_DIR=$DOTFILES_DIR"
dotfiles git status
dotfiles code ~
7reactions
lamusiquecommented, Oct 18, 2021

@lszomoru Look forward to your fix! 🤞🏻

Read more comments on GitHub >

github_iconTop Results From Across the Web

Git - git Documentation - Git SCM
You can learn more about individual Git commands with "git help command". ... (or GIT_DIR environment variable) turns off the repository discovery that ......
Read more >
`dir` vs `gitdir` - isomorphic-git
If you have a non-bare git repository, there are two parts to it: the git directory ... The isomorphic-git equivalent of --git-dir is...
Read more >
git with --git-dir= results in 'not a git repository' - Stack Overflow
To help me remember what to do, I try to remember that the option is asking for exactly what it wants: the path...
Read more >
assistant does not support nonstandard --git-dir - git-annex
Please describe the problem. If using git annex with external .git dir webapp report a tread crashed and ever trying to restart it...
Read more >
Git Directory and Work-Tree Explained - jdhao
Git has two option --git-dir and --work-tree. What is the use for them?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found