kevinmkchin/Obsidian-GitHub-Sync

"Vault is not a Git repo or git binary cannot be found."

DanShui-Yu opened this issue · 14 comments

Hello Kevin. I filled in the information according to the format, but I kept getting the following prompt and couldn't complete the synchronization.

image

I am sure that my personal access token has been opened with all permissions and the repo has been init . There is also a .git folder in the root directory of my vault. What could be the problem?

Or, perhaps, as a novice, my understanding of "GitHub username, personal access token, and the URL for your GitHub repo" is incorrect? Could you please provide a more specific example?

@DanShui-Yu You probably set up the username, PAT, and URL properly. I'm assuming that your system does not know where the git binary is located.

I don't know how your computer is set up, but if you open a raw Command Prompt on Windows or Terminal on Mac and do git -v, does it print your git version? If not then git is not added to your system PATH.

In any case, easiest way to resolve this is to find where your git binary (git.exe) is located and just set that directory in the plugin settings:
image

I made a PR #3 to make the "Vault is not a Git repo or git binary" error message a bit more verbose, maybe that makes setting this plugin up a bit easier

I had a similar issue that was caused by the git binary needing to be specified, even though it's in the default location. Maybe something in this solution process will show the answer. #4

Hello Kevin.
I have same issue. I have installed Obsidian on Ubuntu as Snap.
1.
In the plugin settings I have set: Github username; token; repo url; git binary = /usr/bin/git. And I get:
Vault is not a Git repo or git binary cannot be found.
Problem: Error: fatal: not a git repository (or any of the parent directories): .git
2.
If I don't set git binary field I get:
Vault is not a Git repo or git binary cannot be found.
Problem: Error: TypeError
[ERR_INVALID_ARG_VALUE]: The argument 'file' cannot be empty Received "
Could this be because I use Snap and the Obsidian doesn't access to my file system?

@fitincontact

I can confirm that when installing Obsidian as Snap or Flatpak the plugin won't function as it's not able to find/access Git installed on the system. If you install the regular Deb the plugin should function fine.

For macOS (solution)

You just have to put the git binary location although it optional,
by running which git it will give you the git location. In my case git location is /opt/homebrew/bin/git
Screenshot 2024-06-14 at 10 29 21 PM

After that it will works fine. But some common thing need to check before sync,
Assume that you already created git repo in github then don't forget to add these lines into .gitignore because it contain your github's personal access token which refuse by Github from exposing publicly.

.obsidian/plugins/github-sync/data.json // this is enough but you can also add the bellow or use pattern
.obsidian/plugins/github-sync/main.js
.obsidian/plugins/github-sync/manifest.json
.obsidian/plugins/github-sync/styles.css

basically that's it.

For macOS (solution)

You just have to put the git binary location although it optional, by running which git it will give you the git location. In my case git location is /opt/homebrew/bin/git Screenshot 2024-06-14 at 10 29 21 PM

After that it will works fine. But some common thing need to check before sync, Assume that you already created git repo in github then don't forget to add these lines into .gitignore because it contain your github's personal access token which refuse by Github from exposing publicly.

.obsidian/plugins/github-sync/data.json // this is enough but you can also add the bellow or use pattern
.obsidian/plugins/github-sync/main.js
.obsidian/plugins/github-sync/manifest.json
.obsidian/plugins/github-sync/styles.css

basically that's it.

still not working.

I found a solution, I have to init my git repo in ~/Documents/Obsidian Vault.
Finally, this extension works.

For macOS (solution)

You just have to put the git binary location although it optional, by running which git it will give you the git location. In my case git location is /opt/homebrew/bin/git Screenshot 2024-06-14 at 10 29 21 PM

After that it will works fine. But some common thing need to check before sync, Assume that you already created git repo in github then don't forget to add these lines into .gitignore because it contain your github's personal access token which refuse by Github from exposing publicly.

.obsidian/plugins/github-sync/data.json // this is enough but you can also add the bellow or use pattern
.obsidian/plugins/github-sync/main.js
.obsidian/plugins/github-sync/manifest.json
.obsidian/plugins/github-sync/styles.css

basically that's it.

This did it for me, thanks! Great plugin thanks Kevin.

i get this error.
image

my repository is initialized in the vault, not outside of it. what could be the issue here? Also i am using ubuntu 24.04 and installed the obsidian via the deb package.

also PAT wasn't used once yet if that helps

windows git binary location should be end with “/”,like "G:/PortableGit/bin/"

windows git binary location should be end with “/”,like "G:/PortableGit/bin/"

I am using ubuntu

On macOS, it worked after removing the "git" at the end of the git binary path. It should end with a slash , ie: "/usr/bin/"