obsidian-git icon indicating copy to clipboard operation
obsidian-git copied to clipboard

[Bug]: Git commands pass null in Obsidian, works fine via command line

Open erik4github opened this issue 3 years ago • 3 comments

Describe the bug

When using the commands in the Obsidian UI, nothing works. It's passing null to the command. The remote origin URL and the default branch of master are both set.

Git Pull using Obsidian Git:

obsidian git issue

Git Pull via terminal:

MINGW64 ~/Desktop/Vaults/Programming (master)
$ git pull origin master
From https://github.com/username/vault-repo
 * branch            master     -> FETCH_HEAD
Already up to date.

Relevant errors (if available)

git obsidian error: null
fatal: ambiguous argument 'null': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

plugin:obsidian-git:10679 Uncaught (in promise) Error: null
fatal: ambiguous argument 'null': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

    at Object.action (plugin:obsidian-git:10679:25)
    at PluginStore.exec (plugin:obsidian-git:10704:25)
    at eval (plugin:obsidian-git:8499:43)
    at new Promise (<anonymous>)
    at GitExecutorChain.handleTaskData (plugin:obsidian-git:8497:16)
    at GitExecutorChain.eval (plugin:obsidian-git:8481:44)
    at Generator.next (<anonymous>)
    at fulfilled (plugin:obsidian-git:7333:24)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

Steps to reproduce

  1. Create a repository on GitHub
  2. Create new vault
  3. Install Obsidian Git and enable
  4. Set remote origin to GitHub repo URL
  5. Try any command in Obsidian Git (like pulling the repo)
  6. Try any command in terminal shell

Expected Behavior

Obsidian Git should behave the same as running commands in terminal.

Addition context

Output of git branch info in terminal

$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master

Operating system

Windows

Plugin version

1.26.1

erik4github avatar Jul 14 '22 17:07 erik4github

Does the same happen for stage/commit? Or only for pull?

Vinzent03 avatar Jul 16 '22 17:07 Vinzent03

Found the same issue on mac.

Figured a workaround for getting the sync to work while the bug gets fixed:

  • Create your repo and push the changes from terminal once
  • Delete your local vault and clone the repo into a new folder
  • Open the new clone folder as a vault on Obsidian desktop

This workaround did the trick for me on mac.

anindya avatar Jul 18 '22 01:07 anindya

Tried other commands, Issue was happening because there wasn't an upstream set. git branch --set-upstream-to origin/master fixed it.

Wouldn't have known if if the Obsidian Git Push command error didn't tell me no upstream was set, since Obsidian Git Pull just gave the null error.

erik4github avatar Jul 18 '22 15:07 erik4github