fix: set GIT_WORK_TREE when using custom git directory#1064
Conversation
|
What was the exact issue you were experiencing? Reading the documentation it should be enough to launch the git process from the vault base path which is the case currently:
|
|
The issue I was having was that I have my Git repository outside of the obsidian vault path, and no configuration options would get the plugin to work with that scenario. |
|
Hmm it works perfectly fine for me without that setting. Which git version are you running? ( |
|
|
I could finally reproduce the case. So far, I only tested it by moving the |
|
Yeah, it's a weird pattern, I know. Using a bare repo lets you keep your git work tree completely separate from the git files. Useful if you have some tooling that works with the directory, and you don't want that fooling with the repo/git history. Or if you’re serving those files up, say, via a web server, and you don't want people to access the history either. Thanks for the merge. Also, I didn't know that a |


I have a scenario where I don't want the .git directory to be inside the vault. The reason is because I also have Google Drive syncing this vault Automatically. And I don't want Google Drive to sync the Git files. (Google Drive doesn't have any sort of files-to-ignore configuration)
Unfortunately everything I tried wasn't working. I know this plugin already has support for different Git repo, but with an external git repo you have to specify both the GIT_DIR and the GIT_WORK_TREE explicitly in the environment or through command line options. And this plugin doesn't support that.
This PR fixes that by adding support for the GIT_WORK_TREE. It's not necessary to specify it explicitly as it will default to the vault/base directory. It's harmless to have it present in other scenarios because it will still have the correct value, the base path.
Note
Running
gitfrom within the working directory (basepath) used to be enough, some 15 years ago, but no longer. Also this is completely unrelated togit worktreesupport.