Git plugin on Windows: error: fatal: Invalid object name '"--pretty=format'

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.

Steps to reproduce:

  1. Install Obsidian v1.6.7 on Windows 10
  2. Install and enable Git Plugin v2.27.0
  3. Exit Obsidian
  4. Install Git for Windows v2.46.2.windows.1
  5. Create a new repo on GitHub
  6. Initialize git repo inside default vault location:
cd "C:\Users\<username>\Documents\Obsidian Vault\"
git init
git add .obsidian
git commit -m "Initial commit of obsidian settings"
git branch -M main
git remote add origin https://github.com/path/to/my/vault.git
git push -u origin main
  1. When prompted, authenticate using browser
  2. Open Obsidian, create a new note
  3. Go to “Open Git source control”
  4. Push “Commit-and-sync” button
  5. Commit fails, error is written to developer console

Don’t know this error and not using Git plugin.

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:

[remote "origin"]
	url = [email protected]:<github_username>/<github_repo>.git
	fetch = +refs/heads/*:refs/remotes/origin/*

So for example:

[remote "origin"]
	url = [email protected]:jugdish/myfantasticrepo.git
	fetch = +refs/heads/*:refs/remotes/origin/*

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:

It used to not work on PC, either. I am not using the plugin anymore, so I don’t know about updates for supporting SSH protocol.

You can take your issue to the Git developer by going to the Github repo of the plugin and file an issue.

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.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.