You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a value is set in the Custom Git directory path (Instead of '.git') setting before running the git-init command, any command run after git-init would fail and return an error.
Relevant errors (if available) from notifications or console (CTRL+SHIFT+I)
fatal: this operation must be run in a work tree
Steps to reproduce
In the plugin settings, set a value to Custom Git directory path (Instead of '.git'). For example git
Restart Obsidian
Run the Initialize a new repo command. In my example, it will create a directory called git
Try to run another command (e.g. the command Commit all changes)
Expected Behavior
Git commands should work and not trigger an error.
Running the command git --git-dir=git worktree list from the CLI after running git-ini should return the path to the repo followed by 0000000 [master]
Addition context
Running the command git --git-dir=git worktree list from the CLI after the init indicates that the repo is bare. It shouldn't be the case.
I think this is due to the fact that --git-dir=<git-dir> is used as a parameter to the git-init command.
According to my tests with Git CLI, git init --separate-git-dir=<git-dir> should be used instead. These two parameters cannot be used together.
As a result, the init command will also create a .git text file containing the path to git-dir. This file can be removed as git-dir is already specified in the plugin settings.
Based on the simple-git doc about the git-init command, you'd need to create a condition that tests if gitDir is set.
If it is, then use the following command instead await this.git.init({ '--separate-git-dir': gitDir }, (err) => this.onError(err)); and then delete the .git test file created in the base folder.
Describe the bug
When a value is set in the
Custom Git directory path (Instead of '.git')
setting before running the git-init command, any command run after git-init would fail and return an error.Relevant errors (if available) from notifications or console (
CTRL+SHIFT+I
)fatal: this operation must be run in a work tree
Steps to reproduce
Custom Git directory path (Instead of '.git')
. For examplegit
Initialize a new repo
command. In my example, it will create a directory calledgit
Commit all changes
)Expected Behavior
Git commands should work and not trigger an error.
Running the command
git --git-dir=git worktree list
from the CLI after running git-ini should return the path to the repo followed by0000000 [master]
Addition context
Running the command
git --git-dir=git worktree list
from the CLI after the init indicates that the repo isbare
. It shouldn't be the case.I think this is due to the fact that
--git-dir=<git-dir>
is used as a parameter to thegit-init
command.According to my tests with Git CLI,
git init --separate-git-dir=<git-dir>
should be used instead. These two parameters cannot be used together.As a result, the init command will also create a
.git
text file containing the path to git-dir. This file can be removed as git-dir is already specified in the plugin settings.Refer to the git-init doc for more details.
Workarounds
If no custom
git-dir
value has been set in the plugin settings (CLI not required):Initialize a new repo
command.git
directory to<git-dir>
git-dir
plugin setting to<git-dir>
If a custom
git-dir
value has already been set in the settings (requires using the CLI):git init --separate-git-dir=<git-dir>
.git
text file that's been automatically created (optional)Operating system
Windows
Installation Method
None
Plugin version
2.24.1
The text was updated successfully, but these errors were encountered: