denolehov / obsidian-git

Backup your Obsidian.md vault with git

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Obsidian mobile support

Vinzent03 opened this issue · comments

Because you cannot install git on Android/iOS the plugin has to include git in itself.
Maybe the npm package isomorphic-git is the solution.

Also check out maks/MGit#489, which I thought might be the solution..
As a plugin would be nicer :)

I'm using termux on Android.
https://www.techrepublic.com/article/how-to-install-git-on-android/

Maybe there is a gateway to send shell commands to termux?

I don't have access to Obsidian mobile so I currently use Markor when I want to do some writing on the phone.

Could GitJournal be used as a referenced for this?

@renehernandez this issue is for official Obsidian mobile app, GitJournal is kind of a workaround for this :)

this issue is for official Obsidian mobile app, GitJournal is kind of a workaround for this :)

@denolehov What I was trying to point out is that maybe the plugin could get some ideas of how to integrate with git in mobile from GitJournal.

I know that we want a native integration within the Obsidian mobile app :)

@renehernandez oh sorry, I misunderstood you completely :)

Status update

I decided to use isomorphic-git, which is a "rewritten" git in javascript. Sadly it brings some problems:

The CORS problem is a real problem, because pulling/pushing does not work. It would need a proxy server, which is not very secure. The Obsidian devs have a method to fix CORS, but that's currently not exposed and does not support all features that are needed to push/pull. They have to improve and expose it.

Sadly they have more urgent things to do, so it's not high priority on their list.

So will this be put on hold then?

I am really not happy with this situation, but even the Obsidian dev @lishid said that there is most likely no way for the plugin to fix this without a Server. (Discord message)

I guess I will work on the mobile version (since there is a lot to do), but I won't be able to publish/finish it while this API is not available. I have no clue, when this will be.

Maybe I will publish a version where the user has to insert a proxy server url. So the user can decide over his data.

In addition, I don't own a Catalyst license, so I cannot test it on mobile.
I got sponsored, so I can now test myself on mobile.

I did some huge progress on the pr #66 . Sadly there is a big problem with the file system. I have to customize and proxy the Obsidian adapter. At the moment, the method stat() is still missing on it but thanks to the Obsidian devs, because they are exposing it in the next insider mobile release.
I can't promise it will work, but I hope so. 😉

Would it be possible to fork this plugin to use the Dropbox API in the same way? I wonder if that would be easier for mobile?

@ryanpcmcquen do you mean instead of using git? You can use AutoSync for syncing folders, but then you lose revision history. Or if you meant both I think you'd potentially run into conflicts in the .git folder syncing across dropbox.

@quintrino I mean using only Dropbox, like a separate plugin. Primary use case being iOS users who want some kind of Dropbox support.

Oh right, I forgot that iOS only supported syncing through iCloud.

I'm sure it would be possible, although I'm not sure how much of this existing codebase is tied into the git workflow. It might be better for you to start a new plugin from scratch.

I think a much much much more wiser option would've been to use WASM and just transpile official implementation of libgit. I am not quite sure on the extent this kind of dogfuckery would've taken to do it, but probably much lesser evil than using an implementation of git, that's meant to be ran in web browsers with localStorages n shit

commented

@Vinzent03 thanks first of all for giving us this amazing plugin, it worked flawlessly in Windows 10.
Before coming across this plugin I've had similar idea of using git as backend vault and created shell scripts to sync git and scheduled cron jobs.
I use 3 different devices (work windows 10, personal linux (arch linux) and Android). my approach worked great until I struggled with merge conflicts when I had changes in same lines etc. then found your plugin.
I use termux on android, setting up git and cron in termux is no different. surprised that you didn't make use of it to offer Android support. Cant comment on Ios as I don't have knowledge

This should be possible I think by using a JS implementation of GIT https://isomorphic-git.org/

There is no need to build an existing lib for WASM while this exists.

Also related to: #91

Status Update

Hey I am still alive. I did nothing regarding this issue the last months, because of some frustration. 😅😅 My implementation is mostly done. But I have huge doubt that I will ever be able to publish the update. It was a horrible journey with isomorphic-git and the restrictions on mobile (such as CORS). Now that everything works. There is still a huge problem:

Performance

  • In a repo with 2 commits with 1000 50 lines long txt files and a 10mb pdf it takes 110 seconds to display the changed files modal.
  • In my repo for school notes with many pdfs the app crashes when cloning, because of out of memory.

I doubt that my implementation is the problem. I think isomorphic-git doesn't work well with the limited resources on mobile.
It may work in small repos, but I don't want to publish a plugin which crashes Obsidian.

I am happy about any help. Maybe it's my fault after all.

First, thank you for the update and your work on this! 🚀
If performance is the issue right now, would it be possible to switch to https://www.nodegit.org/ or the WASM approach? Regarding the first option, I am not sure how the app for mobile is actually built and if it is possible to require node libraries, not just browser ones.

That's the problem. You can't use node libraries on mobile.

@Vinzent03 where can we read about limitation for mobile libraries in obsidian?

As long as you don't use any 1) NodeJS modules via require or import, 2) Electron modules via require('electron'), or 3) Vault.adapter, or 4) CodeMirror 5 API, your plugin should work

https://discord.com/channels/686053708261228577/707816848615407697/823558775943331850
That's an answer from Licat(Developer of Obsidian) — 22.03.2021.
But I think point 3 with Vault.adapter is wrong, because that's possible.

But I think point 3 with Vault.adapter is wrong, because that's possible.

I meant using FileSystemAdapter, and associated internals like basePath, etc.


I have a workaround for the CORS issue coming soon in the API. I guess this doesn't really help with the memory or speed issues though.

Just a quick workaround for anyone who needs Git syncing with Obsidian (iOS only) (note this is not ideal, but can work as a good stop-gap imo):

  • Download and setup a vault in the Obsidian mobile app. Don't sync it with iCloud
  • Download Working Copy (There are alternatives for Android, but I haven't tried them)
  • Add your GitHub account in the setup pages
  • Click the + icon and select "Setup synced directory"
  • Commit all recent changes (i.e. the .obsidian folder and some other misc files)
  • Add your git repository as a remote, make sure you choose to sync via SSH
  • Click the fingerprint icon and under the name of your remote select Pull.

This process can be automated at intervals with Apple Shortcuts.

Hope this can help someone :)

Thanks to @Vinzent03 for all the work being put into this, and hopefully we'll have a more cohesive experience in the future

For Android you can use termux, and follow this guide:
https://renerocks.ai/blog/obsidian-encrypted-github-android/

It should probably be mentioned that Working Copy costs $19.99 to use. The only alternative I could find was Polygit for $2/mo or $10/year.

For what it's worth, this is apparently a free iOS method: https://forum.obsidian.md/t/mobile-sync-with-git-on-ios-for-free-using-ish/

For what it's worth, this is apparently a free iOS method: https://forum.obsidian.md/t/mobile-sync-with-git-on-ios-for-free-using-ish/

There is an alternative fir ish as well, a-shell. This one is faster even.
Plus, you can automate everything with WorkingCopy free version and use ish or a-shell to just push manually sometimes. Atleast for a non-programmer, workingcopy would offer a clean interface as to conflicts.

A little bit offtop

As a workaround for now, as it was already mentioned, one can use termux on Android. I use it to sync my vaults in read-only-from-mobile mode to avoid any merge conflicts. Maybe it will be useful for someone :)

Setting up termux:

apt update && apt upgrade && apt install git
git config --global credential.helper store
git clone https://github.com/author/repo-name
# login = login, pass = Personal Acces TOKEN
# here grant the storage access permisson in the android settings
termux-setup-storage
mv repo-name storage/shared/Documents
echo "cd storage/shared/Documents/repo-name && git reset --hard && git pull" > sync
chmod +x sync
./sync

Also I have a .gitignore:

.obsidian/workspace
.trash
.obsidian-git-data*
conflict-files-obsidian-git.md

My workflow to pull changes to the mobile:

  1. Open the Termux
  2. Type ./sync and press enter
  3. Exit Termux
  4. Profit!

For a big workaround, you can use Folder Sync
This will sync your data with your cloud. But without using git.

For a big workaround, you can use Folder Sync
This will sync your data with your cloud. But without using git.

The whole discussion is about git, the cloud sync that too on android is common knowledge, I guess? It is mentioned even on the forum :)

For what it's worth, this is apparently a free iOS method: https://forum.obsidian.md/t/mobile-sync-with-git-on-ios-for-free-using-ish/

There is an alternative fir ish as well, a-shell. This one is faster even.
Plus, you can automate everything with WorkingCopy free version and use ish or a-shell to just push manually sometimes. Atleast for a non-programmer, workingcopy would offer a clean interface as to conflicts.

on IOS
To add to this, a-shell has Shortcuts too. So basically now pushing and pulling is available at the push of a button either in widgets or from home or dock. 🥳

Stupid question: Why don't you copy the implementation from Obsidian Sync?
As far as I understood from reading this issue, there is not yet a working / performant / native implementation of Git on mobile platforms. However, the paid service Obsidian Sync looks to me exactly like a feature that is built upon some version control system, maybe it is even based Git already? So what about contacting Obsidian and ask how they did it?

@mschroen Are you sure that the Obsidian developers are going to share what they are using to generate half of their revenue? I am not even sure if it's based on git. Obsidian sync is definitely the easiest variant. If you want to use it, pay for it. Some of the above comments have many upvotes, so maybe take a look at them.

@mschroen Are you sure that the Obsidian developers are going to share what they are using to generate half of their revenue?

Just recently I fell in love with Obsidian and its plugins, so my romantic perspective may still be contaminated by emotions. So yes, I tend to believe that Obsidian could be an open-source community-driven project where developers at least talk to each other.

In this special case, I do not see too much of a problem: in this issue we are looking for a solution which would be beneficial for people with own Git servers or accounts. These are mainly developers anyway, and I would expect Obsidian to keep its relationship to those users very clean. The revenue created by Obsidian Sync probably comes from a much larger group of people who do not have own remote repositories. Hence: if we would find a solution here, it would be a solution for repository-owners only, and as such would probably have very minimal effect on Obsidians revenue.

I am not even sure if it's based on git.

The whole description of Obsidian Sync features reads to me as if there is a Git-like environment behind it.
The discussion here looks like that the main problem is that there is no Git-library on mobile platforms that can be used to implement the required functionality. My thinking was to find out whether Obsidian Sync already developed and uses such a library, and whether we could gain access to their methods.

Obsidian sync is definitely the easiest variant. If you want to use it, pay for it. Some of the above comments have many upvotes, so maybe take a look at them.

Most of the workarounds are not platform independent and not practical, and none of them actually solve the fundamental problem of implementing Git functionality within Obsidian. I am just trying to be helpful here. But I'd fully agree that my suggestion could be fruitless, that's why it started with "Stupid question:".

A little bit offtop

As a workaround for now, as it was already mentioned, one can use termux on Android. I use it to sync my vaults in read-only-from-mobile mode to avoid any merge conflicts. Maybe it will be useful for someone :)

Setting up termux:

apt update && apt upgrade && apt install git
git config --global credential.helper store
git clone https://github.com/author/repo-name
# login = login, pass = Personal Acces TOKEN
# here grant the storage access permisson in the android settings
termux-setup-storage
mv repo-name storage/shared/Documents
echo "cd storage/shared/Documents/repo-name && git reset --hard && git pull" > sync
chmod +x sync
./sync

Also I have a .gitignore:

.obsidian/workspace
.trash
.obsidian-git-data*
conflict-files-obsidian-git.md

My workflow to pull changes to the mobile:

1. Open the Termux

2. Type `./sync` and press enter

3. Exit Termux

4. Profit!

You can even use a Termux:Widget to run the sync script with a single tap from your mobile home screen 😉

The wiget costs 2$ - which I spent, since I didn't want to open termux and type into a console just to synchronize Obsidian.

Status Update

Hey I am still alive. I did nothing regarding this issue the last months, because of some frustration. sweat_smilesweat_smile My implementation is mostly done. But I have huge doubt that I will ever be able to publish the update. It was a horrible journey with isomorphic-git and the restrictions on mobile (such as CORS). Now that everything works. There is still a huge problem:

Performance

* In a repo with 2 commits with 1000 50 lines long txt files and a 10mb pdf it takes 110 seconds to display the changed files modal.

* In my repo for school notes with many pdfs the app crashes when cloning, because of out of memory.

I doubt that my implementation is the problem. I think isomorphic-git doesn't work well with the limited resources on mobile.
It may work in small repos, but I don't want to publish a plugin which crashes Obsidian.

I am happy about any help. Maybe it's my fault after all.

@Vinzent03 Are you already decided, that you want to use keep using isomorphic git for the Obsidian Mobile version? For me personally, I would miss the features which isomorphic-git does not include due to it's inherent limitations. Especially, since merge resolution will be nesessary when I use the mobile and desktop version of Obsidian frequently.

The setup some of us are using - via Termux - works quite reliable. I know, that it seems like an overkill to have a linux terminal on your Android just for git - but that seems to be the only way to get a reliably working git commandline to work on a mobile device.

I use a Termux widget to start the synchronisation with a single tap on my home screen. I don't even have to do this before opening and editing my obsidian files, as the sync-scripts makes a commit and only then merges with the remote and pushes it.

I added a few extra lines in the script, so that any changes in a few specific files / folders (e.g. .obsidian/workspace) are reset and not pushed. the primere reason, why I like this setup, is that it automatically takes any settings and plugins which I set on my desktop. The only drawback is, that I cannot make settings changes on mobile, as they are discarded before commit.

In total, I am quite happy with this setup - especially with the possibility of having the mobile versions .obsidian/workspace not mixed up with the desktop version. From this description, can you tell me what you think is in favor or or is againt going such a path where git is replicated almost perfectly? This setup didn't have any of the problems with isomorpgic-git - except that sometimes special characters in the file names break git. But that's the only problem I've ever had.

What do you think?

@GollyTicker So you want the plugin to include a Termux like linux terminal to be able to run "native" git?

My question is whether this could / would be a viable alternative. Isomorphic-git has inherent limitations - and most of the people who want to use Obsidian-Git on Mobile (despite Obsidian Sync being a good alternative for most use cases) are going to be developer-ish people. From this perspective, it might make sense to say, that Obsidian-Git for mobile is unavailable per default on mobile - but that power-users who really want it have a small workaround to activate this "experimental" termux-like Obsigien-Git. It can then use either an existing termux git repository (similar to how it works currently on desktop) - or use an internal embedded termux and manage an internal git repository. In the first case, we would only need to know how we might run a termux script from inside an Obsidian Plugin inside the Obsidian App 🤔

This setup will almost certaily not work directly as Install-&-Go. But as most users for this might be developers, we could request the user to make a few extra manual steps during initial setup and plugin update.

While I am able to help in some minimal way - I think it's more important to know, how you stand to this approach. After all, you have already implemented almost all using isomorphic-git and went through much of effort to make it work - kudos for that 🥳
However, if you think, the simpler and less edge-cases way of working with a native git is worth it, then we can continue this discussion.

I just want to chime in (to help answer the question for @mschroen ) that Obsidian Sync uses a completely independent implementation, optimized for real-time (or near real time) synchronization as well as to support end-to-end encryption. There's also many technicalities in the sync algorithm such as automatic conflict resolution.

The way we do things is inherently incompatible with Git, which is diff-based despite sharing some commonalities (like version history). There are some very critical differences under the hood, such as Git is completely based on hash-chains while Obsidian Sync is based on single files.

I just want to chime in (to help answer the question for @mschroen ) that Obsidian Sync uses a completely independent implementation, optimized for real-time (or near real time) synchronization as well as to support end-to-end encryption. There's also many technicalities in the sync algorithm such as automatic conflict resolution.

The way we do things is inherently incompatible with Git, which is diff-based despite sharing some commonalities (like version history). There are some very critical differences under the hood, such as Git is completely based on hash-chains while Obsidian Sync is based on single files.

Thanks for clarification! Also Overleaf seems to use Git for their real-time synchronized collaborative live-editing feature, so I thought this may also apply for Obsidian. But if you already know in detail how Obsidian Sync works, then this question can be simply rejected (:

@mschroen It's Licat from Discord. He is one of the Obsidian developers, so he knows how it's implemented.

But if you already know in detail how Obsidian Sync works

Yup, wrote it myself 😹. It's not as much of a "trade secret" since anyone can just inspect the minified code, but we did put a significant amount of effort into handling all kinds of hairy edge cases and we'd rather not make it easy for anyone to pick it up and sell their own commercial sync service.

Either way - I don't see a way of making it compatible with Git at all since it's implemented much more like Dropbox or Google Drive internally.

@lishid

To be fair, I'm only invested in this because I consider the sync price to be uneconomical. I host several services (Including my hosted obsidian vault, AND semi-published vault) for $1/m more than it would cost to just sync KB/s of text with the discount... Been playing around with some crude diffing setups that are not git, but it has a lot of problems still, but the price keeps me motivated enough to play around with it.

Idk if this holds true for others, but it is my $0.02

Of course - Hard drives these days cost about $0.025 per GB and it's pretty trivial for anyone experienced with tech to setup a home sync server for no additional cost. AWS is priced around the same, plus bandwidth. It's really hard to compete on price these days for storage.

We instead offer convenience for those who don't have time or expertise to tinker with something more advanced for a cheaper overall cost, because after all, time is money 😉.

commented

Hi!
Just wondering if you've continued to work on this.
Is native git through wasm an option?

@Icelk I don't have much time at the moment. Haven't really tested it yet.

commented

@Vinzent03 Thanks for the swift reply!
I might look into it a bit.

I might look into it a bit.

And inform here please. :P

commented

UPDATE: https://forum.obsidian.md/t/obsidian-release-v0-12-16-insider-build/24166

  • request can now set HTTP headers.

Does this mean CORS is no longer a problem?

@meetcw I think yes. (If the git alternative supports specifying an own http client)

request can now set HTTP headers.
Does this mean CORS is no longer a problem?

I think yes. (If the git alternative supports specifying an own http client)

CORS headers are set by the server and the web browser enforces it. The client doesn't get a say in the allowed origins of the server.

If the requests where to be sent from the NodeJS process instead of the chromium process, then this is a non-issue.

Then again, maybe I'm missing something here?

@douglasg14b The problem of Obsidian mobile is the missing NodeJS part. The mobile version is much more a Browser, so it's affected by CORS. Luckily, the Obsidian devs provide a work around over native ways.

@Vinzent03 Gotcha.

For the mobile app, w/e wrapper it's using (ie. Cordova), would have the ability to send HTTP requests I think. Unless it's just a PWA?

commented

@douglasg14b Obsidian for mobile seems to be based on capacitorjs.

https://news.ycombinator.com/item?id=27807850

Gotcha, this is what came up when I looked at it: https://capacitorjs.com/blog/bypassing-cors-with-the-http-plugin

If the main issues are related to CORS, would this be fixable by self-hosting some proxy to git that allows cross origin requests without issue?

commented

@elkowar That should work.
Now that I'm thinking about it, we can't send Git requests from a Web app; Git servers don't understand HTTP.
We would need a proxy anyway.

I mean that's what isomorphic-git does, no? Allow git access from the web. Hosting a proxy would be an easy solution - although if it's somehow possible to work around the cors issues without one, that'd of course be preferable

@Icelk

Git servers don't understand HTTP
I don't think so. Git itself doesn't care it's about the hosting, for example GitHub, which supports HTTPS.

Have you tried WASM git?

And as I said in a previous comment, CORS is currently not the problem. Running a git version is the problem.

commented

I mean that's what isomorphic-git does, no?

Right, forgot about that.

@Vinzent03 I have not. Would be nice to bundle WASM git and a setup for setting the email and name, for users without a git config.
This could be done for both desktop and mobile; an universal solution.

It should probably be mentioned that Working Copy costs $19.99 to use. The only alternative I could find was Polygit for $2/mo or $10/year.

It's well spent money for Working Copy. I use that app for many years already and it's the only good Git app on iOS and also the only Git app that was able to implement and integrate into the iOS storage layer in a way that third-party apps like obsidian can use it (no vfs via FileProvider and proper background sync).
This is the only working way I found to setup Git sync in a performant and usable way.

Hello everyone. I'm brand new to both the app and this plugin but extremely keen to see it flourish. It seems that CORS has been addressed and seems to be working:

Now that everything works. There is still a huge problem

it also looks to me like it is in fact working just fine but there are limitations on sizes, Lots of files == big commit == lots of processing. So 1000 files will take a good minute or two to pull down from the remote. On the other hand, large Binary files cannot be compressed as easily and therefore are much more likely to Crash the app:

  • In a repo with 2 commits with 1000 50 lines long txt files and a 10mb pdf it takes 110 seconds to display the changed files modal.
  • In my repo for school notes with many pdfs the app crashes when cloning, because of out of memory.

So are those the main 2 problems? Both being the direct result of the isomorphic-git library and the contexts it's executed in (browser).

If this is the case then a working version exists with the limitations of being slow and prone to crashing with large amounts of data. This could be released as-is with a warning that it will likely not work or have degraded performance on mobile.

After looking through capacitorjs a bit I have realized that realistically the only way that git could be used with the local file system would be if the Obsidian team added https://capacitorjs.com/docs/apis/filesystem and allowed plugins access. This could theoretically be done, and a custom fs module could be written for isomorphic-git to replace the fs but it's not guaranteed to fix the problems or help at all.

I'm just excited to see this project so active in such a recent timespan (I'm used to year old issues)

Perhaps an impopular opinion (sorry!), but as far as I'm concerned, Obsidian Git doesn't need to work on mobile (at least not on iOS/iPadOS). I'm fine with just leaving it to Working Copy, which provides a native Git. I much prefer the reliability of a manual sync with a native git over a potentially less reliable solution that requires the obsidian-git maintainers to jump all kinds of hoops, even if the latter can be automated.

I also really liked the suggestion by @wyatt to use Shortcuts, which potentially means I don't even need to sync manually anymore. I'm going to investigate my options on that front.

Success! To set up simple automatic syncing with Working Copy on iOS/iPadOS, you can take the following steps.

  • If you have not already done so, create the repository in Working Copy and ensure that manual push/pull works (create a non-iCloud vault in the Obsidian app first, then open Working Copy and create a new repo with "External directory" or "Synced directory").
  • Add this Shortcut to your home screen, name it "Obsidian" and use it to launch Obsidian instead of the app itself. This will take care of the initial pull when opening the app.
  • Import this Shortcut and use Automation to run it when you close the Obsidian app. This will commit and push your changes.

The latter shortcut lets you customize the commit message, but it will be the exact same message every time. I use it just to distinguish commits from different devices. If you want a more sophisticated, dynamic commit message computation, you can add some of your own programming to the shortcut. Shortcuts can do string processing, retrieve dates, etcetera. Customizing will also let you handle more advanced situations such as having multiple vaults.

I guess that if there were a git client on android that could have both the save and get changes routines as widgets shortucts, that would be great. Maybe even automated with something like tasker.

I guess that if there were a git client on android that could have both the save and get changes routines as widgets shortucts, that would be great. Maybe even automated with something like tasker.

You can use Termux to set up scripts and widget shortcuts for pulling/pushing (see https://renerocks.ai/blog/obsidian-encrypted-github-android/#android); it works, but it still is not an ideal workflow imo. It would be good if these steps could be done within Obsidian, and even better if they could be done automatically (e.g. on open/close of the app, #13 ).

fwiw I have a workaround for this using gitjournal, an android app that has git built into it. I just point it at the same folder that obsidian uses on my phone. not ideal, but workable. maybe of interest.

gitjournal looks good, unfortunately I seem to have some issue with external folders and miui permissions, so I'm using the app itself as a viewer.
But maybe the git implementation can be borrowed?@Vinzent03
https://github.com/GitJournal/GitJournal

@rzfzr I don't think so, because they use libgit2, which I don't think can we use in a javascript app. I think the only way is wasm git, but still haven't the time for it.

@Vinzent03, maybe instead of trying to provide a generic solution for Git, it would be better to just settle to a service such as GitHub or GitLab and use the API to push/pull/merge?

What about using the x-callback-url interface in "Working Copy" for iOS? https://workingcopyapp.com/url-schemes.html#x-callback-url -- yes, they'd need to buy a third-party payware app, but now that CORS is fixed, you can send these URLs and use working copy's binary git implementation and git repo config to push and pull at will, like other versions.

wasm-git's example seems simple enough: https://github.com/petersalomonsen/wasm-git/blob/master/examples/example_webworker.js
Wish I had the time to contribute

password-store has git integration with ssh (you need ssh support else it's nearly pointless) What about referring to their implementation?

@Vinzent03 or @rzfzr, what level of sponsorship would be required to get this implemented (presumably using wasm-git) and in what time frame?

@matthiasmiller I'm not working on this at all, but cool Ideal, I'm willing to sponsor aswell

AFAICT, we bypass the CORS problem by using Obsidian's request HTTP client.

wasm-git's example seems simple enough: https://github.com/petersalomonsen/wasm-git/blob/master/examples/example_webworker.js Wish I had the time to contribute

Does wasm-git allow us to specify an HTTP client? It seems it just uses XMLHttpRequest. And since this is complied down to Web Assembly, we'd need to change this to Obsidian's request and then compile? I'm not familiar with this though, so do let me know if I'm misunderstanding something!

Related: @Vinzent03 said CORS wasn't an issue anymore, presumably because of this Obsidian request function. But I don't see it used anywhere in his branch; I just see import http from "isomorphic-git/http/web"; . @Vinzent03 or anyone else, is the branch just not up-to-date or am I wrong about how to bypass CORS here?

@matthiasmiller @rzfzr Thanks for your will to sponsor, but I would have to make sure that it works at all before. In my last try I got nothing to work 😂 In addition comes the problem @warrenalphonso mentioned. I would need to pass my own http client. And I'm not sure/ I don't think that is possible.

@warrenalphonso The branch is very old. The request function was added later. I didn't update the branch, because that's not the biggest bottleneck. It's the performance.

that's not the biggest bottleneck. It's the performance.

Performance of the Git client no? If it were possible to pass our own HTTP Client into WASM-Git that would solve the problems and increase performance to a usable level?

If that is the case it seems to me like it is achievable albeit with a more work

An Android workaround I haven't seen mentioned is MGit.

I've only started using it but it seems to work well enough.

fwiw I have a workaround for this using gitjournal, an android app that has git built into it. I just point it at the same folder that obsidian uses on my phone. not ideal, but workable. maybe of interest.

Do you still use it? if so could you please check the version? I keep getting the external location error

@rzfzr I have the same error with Android 11. I asked Vishesh (the developer) and he said it was an issue with Android 11 file permissions. I filed a bug report a few weeks back, but so far no updates have been made.

GitJournal does seem to be the best solution though (when it works).

Again, I suggest checkimh out what the Android password-store developers are doing to have git in their application.

For Android support, at least as a reach around, I've had success using GitNex to push, pull, work with repos without being in the actual code-forge.. +++ it has multiple git accounts support

For Android support, at least as a reach around, I've had success using GitNex to push, pull, work with repos without being in the actual code-forge.. +++ it has multiple git accounts support

There is no such thing as a git account.

Mgit is working well on Redmi K30 Pro Zoom Edition

commented

It might be worth looking into how this app does it in a cross platform way: https://github.com/GitJournal/GitJournal

@snowzach I know it was looked at in the past here #57 (comment), do you know if they've updated their approach since then?

commented

So I am pretty good with Go which can output WASM. I don't know much about WASM but I am interested in this enough to try to figure something out. If I can get the interface required to support this, I could possibly start looking at it. There's an entire git client in Go that might be useful but if we just need the minimal pieces of it, I could look at that.

... So I read through the code and it looks straight forward enough. The thing I am not sure of is if WASM can read the filesystem. All indications point to no which means this won't work.... Unless I am missing something?

Just random thought, but seems you could avoid the file issue by asking the user to store an ssh token in a secret gist. And using GitHub permission mode to access that token from the gist and passing it into the git client when needed. I think the vscode extension Settings Sync does something similar

Interesting issue. This is probably the only issue keeping me from switching to obsidian for my notes. So I decided to help.

I usually reverse engineer android apps and malware, so I got a little experience with the terminal stuff.

I can see there's a few ways to achieve git feature.

  1. Use termux API to call git
  2. Use a git binary (limitations on android 10+ will cause problems).
  3. Make a android service app that has libgit2 / git binary, and make public intents in it. Use obsidian to call those intents with parameters so it executes git. (Like tachiomi plugins).
  4. Use wasm (rust, go, nim, c++ suggested)
  5. Use respective git service api

I can help in these (except number 4. Never used wasm).

Why Git tho? i mean it's fine, but what we really want is a file hosted on the cloud. and a server to push to and pull from.
and the changes are linear, hence git is an overkill.
i'd rather create a netlify website to host these files.
or if maybe web3 storage.

Why Git tho? i mean it's fine, but what we really want is a file hosted on the cloud. and a server to push to and pull from.

Cause we're in obsidian-git not obsidian-netlify probably. That's like off-road.

Sidenote:
I have already made a custom commit system for cloud storages to keep track of vault changes. But it's nowhere near the real thing, that is git.

Make a android service app that has libgit2 / git binary, and make public intents in it.

I think the author of MGit might be amenable to a PR that extends MGit to do this: maks/MGit#489

Seems like MGit really want their app to be purely based on the GUI purpose rather than having it used like a plugin app sort of.

Which is understandable. I also wouldn't want people asking me why git merge failed error shows up during pushing their notes.

It seems the only way here is to fork the project to another name (with their due respect ofcourse), and make a seperate one with the PR merged, and keep updating the base.

Hi there, so what's the progress on this one? As far as I understood it's mostly trying to settle on a git implementation? I think embedding a minimal git lib would be the most user friendly approach so that people don't have to mess with external stuff, and it would also allow to make the library smaller since obsidian-git doesn't use all of the features of git like bisect and cherry pick, only commit, pull, push, add and maybe log, which is a very small subset of what git can do

mgit is having an issue adding files to staging making it un-useable at the moment. GitJournal seems able to handle git repos well.