[Mobile] Automatic sync with GitHub on iOS (for free) via a-shell

Thanks
Now i can “backup” my vault on my Windows10 computer with Github.

Now i have to thinks about how recover the vault in my iphone.

Thanks a lot again !!!

Update on the config memory tweak.
All working really well. No memory issues whatsoever. Lg2 add and status are slower than before but as long as it’s reliable, I don’t mind. In the .git/objects/pack folder there is a recently updated 750MB chunk, though, which means 1) the tweak is actually useless 2) it’s not useless, it is the size of my vault and was packed like that by default and incidentally gets a modified stamp.
Time will tell. A git repo needs maintenance.


Also, another tip.
It is fairly trivial to JB one’s device these days (palera1n). Once that’s done*, go into Obsidian’s Documents container in Filza, make a symlink of your repo folder, cut and paste it into Working Copy’s Documents folder, and voila, you can pull and add+commit for free (you can push with A-Shell), this time in a repo outside of WC’s allocated folder, that is in your very own Obsidian onMyiPhone/onMyiPad folder.

  • WC can come in handy when handling file conflicts (doing that is a bit troublesome with git/lg2). Also, the app indexes all your files in the repo and they become content-searchable in iOS Spotlight.

* It’s temporary JB at this time and there are limitations for devices with newer processors, of course.

Since using WC together with A-Shell, for some reason the execution of the lg2 add-commit-push sequence in my Siri Shortcut (with WC not running anywhere, neither in foreground nor in background) is 5 (10?) times faster.
Interesting…

One other issue found

sometimes the jump obsidian command fails.

it might be related app-bundle-id changes that occurred after updating apps (maybe related to other reasons)

Does anyone know to find this bundle-id dynamically? (without the pickFolder command)
The pattern looks like /private/var/mobile/Containers/Data/Application/app-bundle-id/Documents

You could start a conversation with the dev on the app’s GH site by raising an issue. He is very responsive and helpful.
Actually, I was thinking of contacting him myself as I am having a hard time as well, especially when combining multiple commands and running them with a Shortcut.

I also tried editing the preferences of the app (with JB file manager Filza) before but the changes didn’t stick.

Hi guys,
I’m the developer of a-Shell. I’m really happy that you found it useful. I’ll try to monitor this place regularly if you have more questions.

To answer some of your questions:

  • when an app is updated (because there is a new version), then its location on the disk changes. That is why your key locations in lg2 were becoming invalid (lg2 had expanded “~/” to “/var/mobile/Containers/…/”, and the things inside the “…” had changed, so the key was not there). Since version 1.11.0 (a month ago), lg2 tries to be smarter and recognises “/var/mobile/Containers/…” and stores it as “~”, so the position of the ssh keys should now remain valid after a-Shell is updated.
  • bookmarks can become invalid too. Why and when that happens is a mystery. It shouldn’t happen too often, but there’s no fix. The only solution is to regenerate the bookmark.
  • “jump obsidian” works, but “cd ~obsidian” should also work, if you prefer the latter.

I hope this helps, let me know if you have more questions.

2 Likes

Thanks for the tips!

I’ve been trying to get the a-Shell Shortucts to not open the app (run in extension), as I think that would significantly reduce the jankiness of this process. However, lg2 pull and push both time out the shortcut command. Any idea on why that is? Do these commands have to be run by opening the app?

If you JB your device and use local SSH Shortcut action (with git instead of libgit2) + Newterm terminal, the process is considerably faster and hassle-free (but it’s worthwhile to keep the A-Shell workflow in the Shortcuts app).
Not to mention the fact it will open whole new possibilities with regard to automation.

I can’t seem to push changes from mobile to the repo as this keeps popping up:

SSH authentication: Using private key: /var/mobile/Containers/Data/Application/058F3994-023F-4AB0-8E12-CA44986A08E8/Documents/.ssh/sha256:sM.....
Error pushing [-1] - Failed to authenticate SSH session: Unable to open public key file

What am I doing wrong? I’ve successfully pulled from obsidian but can’t seem to push. Same problem in both my iPad and iPhone. Any help?

Funnily, it worked after I reentered this lg2 config user.identityFile "~/Documents/.ssh/id_ed25519"
I already did enter it so don’t know what made it work the second time, but happy for now!

So now everything is working okay. Except that my changes are being sent to a separate main branch and I have to merge pull requests individually.
Any help with that? Thank you so much :slight_smile:

Tough question. The “extension” and the app are two different apps from Apple’s point of view, so they have different home directories (~ points to a different place). That changes the behaviour for a lot of things. The extension does not have access to the home directory of the app, and the app does not have access to the home directory of the extension. You will need to experiment, but I would try:

  • copy the .ssh directory to ~shortcuts (from the app)
  • in extension, set SSH_HOME to ~shortcuts/.ssh (setenv SSH_HOME $SHORTCUTS/.ssh)
  • retry the lg2 commands.

ok guys. I faced the jump (marks) lost issue again and found the other solid solution.

If you guys are using iOS, and Mac use iCoud Sync is a reliable option!

(a bit shame I didn’t know this kk.)

anyway thanks for amazing contributes siris and other guys in this thread.

thank you!

Are you in the wrong thread? This is about syncing with git.

Whats this can someone explain how to solve it?

According to the error message, the folder ~/Documents/.ssh does not exist, so lg2 cannot find your SSH keys. You’ll have to create the keys first (and copy them to your git server).

1 Like

Hello
I created a repo with my vault that i synchronized beetween my PC and github.

I installed the a-shell on my iphone
I installed the Obisidian mobill app

But i did not understand the way to push my vault on my iphone.

Do you know what i have to do ?

Hey , its working properly but is there any way to not push the .obsidian directory into github?


Whats this

You have to create a .gitignore and add the files/directories you want git to exclude. See here for more specific info:

My .gitignore, for example:

.obsidian/appearance.json
.obsidian/workspace.json
.trash/
.obsidian/workspace-mobile.json

For a lot of your questions, googling the error or what you want to do will return information that is more useful and will be faster than asking here.

2 Likes