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

Obsidian mobile support

Open Vinzent03 opened this issue 3 years ago • 108 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.

Vinzent03 avatar Mar 22 '21 14:03 Vinzent03

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

xeor avatar Mar 23 '21 14:03 xeor

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.

kalitara avatar Apr 04 '21 12:04 kalitara

Could GitJournal be used as a referenced for this?

renehernandez avatar Apr 05 '21 13:04 renehernandez

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

denolehov avatar Apr 05 '21 14:04 denolehov

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 avatar Apr 05 '21 14:04 renehernandez

@renehernandez oh sorry, I misunderstood you completely :)

denolehov avatar Apr 05 '21 15:04 denolehov

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.

Vinzent03 avatar Apr 11 '21 15:04 Vinzent03

So will this be put on hold then?

renehernandez avatar Apr 12 '21 18:04 renehernandez

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.

Vinzent03 avatar Apr 13 '21 18:04 Vinzent03

~~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.

Vinzent03 avatar Apr 15 '21 18:04 Vinzent03

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. 😉

Vinzent03 avatar Apr 20 '21 17:04 Vinzent03

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 avatar May 20 '21 00:05 ryanpcmcquen

@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 avatar May 21 '21 03:05 quintrino

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

ryanpcmcquen avatar May 21 '21 03:05 ryanpcmcquen

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.

quintrino avatar May 21 '21 04:05 quintrino

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

bppdddqqqq avatar May 28 '21 21:05 bppdddqqqq

@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

prashant2402 avatar Jun 26 '21 14:06 prashant2402

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: https://github.com/denolehov/obsidian-git/issues/91

douglasg14b avatar Jul 15 '21 01:07 douglasg14b

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.

Vinzent03 avatar Jul 15 '21 11:07 Vinzent03

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.

Duske avatar Jul 15 '21 12:07 Duske

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

Vinzent03 avatar Jul 15 '21 12:07 Vinzent03

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

vanadium23 avatar Jul 15 '21 16:07 vanadium23

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.

Vinzent03 avatar Jul 15 '21 16:07 Vinzent03

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.

lishid avatar Jul 15 '21 16:07 lishid

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

wyatt avatar Jul 15 '21 19:07 wyatt

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

vanadium23 avatar Jul 15 '21 20:07 vanadium23

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.

steven-kraft avatar Jul 16 '21 15:07 steven-kraft

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/

eleanorkonik avatar Jul 16 '21 16:07 eleanorkonik

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.

dummifiedme avatar Aug 12 '21 04:08 dummifiedme

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!

m-danya avatar Aug 19 '21 20:08 m-danya