I am brand new to Obsidian, just installed a fresh copy and enabled the Git plugin, followed the instructions for setting up my vault with it, and I immediately ran into an error on my first attempt to “Commit-and-sync”:
loading Git plugin: v2.27.0
plugin:obsidian-git:314 obsidian-git: error: fatal: Invalid object name '"--pretty=format'.
plugin:obsidian-git:104 Uncaught (in promise) Error: fatal: Invalid object name '"--pretty=format'.
at Object.action (plugin:obsidian-git:104:10649)
at zF.exec (plugin:obsidian-git:104:10960)
at eval (plugin:obsidian-git:103:6654)
at new Promise (<anonymous>)
at Xf.handleTaskData (plugin:obsidian-git:103:6543)
at Xf.eval (plugin:obsidian-git:103:6169)
at Generator.next (<anonymous>)
at a (plugin:obsidian-git:100:11259)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
plugin:obsidian-git:314 obsidian-git: error: fatal: Invalid object name '"--pretty=format'.
Has anyone ever encountered this before? I’ve searched around and found nothing. I’m probably doing something wrong, but no idea what, considering everything is brand new and empty and I’m following the online documentation, there’s little room for me to have gone astray already.
This part looks faulty.
If you enter the .git folder in your file explorer, check the config file.
The part relating to that command should look like this:
You can edit and save this config file without adding any commands in terminals or Git plugin.
Then try again.
Having said this, I seem to remember the Git plugin not handling SSH protocol but HTTPS, so url should be: https://github.com/jugdish/myfantasticrepo.git
So because Git authenticates via GitHub tokens (formerly passwords could be used), not via SSH keys, you will need to add your personal token in the settings so push and pull would work.
Yes as you noted, the SSH style git URL does not work on mobile with the Obsidian Git plugin, which is why I’m opting to use the HTTPS style git URL. The exact path is personal which is why I put in that placeholder URL, but I have double-checked that I am using the correct URL (the one that is returned by the “git remote -v” command when I am inside my vault where the .git folder lives).
I have also verified that I can successfully run “git pull” and “git push” from the filesystem. The first time I did this it prompted me to authenticate, which I was able to do using a web browser. After that, all calls to “git pull” and “git push” are able to use the cached credentials without prompting.
So, I am confident that the git repo is cloned correctly and I have confirmed that pull and push work outside of Obsidian, it is only when trying to do it inside Obsidian that it is failing.
I believe the error I’m getting is the result of some malformed command that the Obsidian Git plugin is constructing. When I increase the verbosity in the developer console, I can see the contents of some arrays that it’s passing around, and the “–pretty=format” argument looks like it contains incorrectly encoded characters, as you can see from this screenshot:
In the meantime, on Windows, you can use GitHub desktop using this tutorial.
On mobile, it’s trickier and depends on what OS device you have. On iOS, there’s A-Shell, on Android, I don’t know. Possibly you can use Termux terminal as they talk about it here.
There might even be dedicated apps that can do git and are more advanced than MGit, for instance.
I have fixed the issue. It turns out Obsidian was not actually picking up Git v2.46 like I thought it was, because there was older Git version (v2.21) that was bundled with Cygwin64 that was winning out in the System $PATH order. So I removed that version and now Obsidian is picking up Git v2.46 and the problem is resolved.