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

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

Thank you for the amazing post ! The only thing that was preventing me going full for obsidian is its mobile sync - default option of icloud made it so sluggish. I tried syncing with Obsidian Git plugin itself on iphone - which worked without requiring any other app - but the experience was very clunky - The Obsidian-Git plugin throws lot of messages and what not.

Your solution is perfect as far as reliability of sync is concerned.

Only thing now left is - shortcuts and automations to make things seamless.

I am able to execute the shortcuts using Commander and Shortcut Launcher plugins as discussed in this post - but when shortcut is launched from within the obsidian - the a-shell app does not execute the commands and shortcut moves to the next step. The expected behaviour is to execute the whole command on a-shell and then run the next step in shortcut which is to launch the Obsidian. Even better solution would be to execute the a-shell commands in the background itself when the shortcut is moved to next step for launch of Obsidian

I partially solved this problem by putting up a waiting period of 10 sec between the shell execution of command and next step of launching back of Obsidian app.

Have you also experienced the same or am I missing something here?

Again Thanks a ton for your post :slight_smile:

Seems like I ran into same issue -

I am facing the same message when I ma trying to run pull shortcuts - lg2 merge exit code incorrect · Issue #667 · holzschu/a-shell · GitHub

And similar error as in the screenshot above when trying to run push shortcut

And nothing seems to work now.

Finally Resolved the conflicts using the Working Copy app and then added workspace-mobile.json file to .gitignore file. It worked now.

2 Likes

I was having some issues with the lg2 pull having conflicts. I but I found that replacing that line with lg2 stash lg2 pull lg2 stash apply resolved it. Just wanted to let people know.

2 Likes

thanks for this information

I keep getting this error :slightly_frowning_face: . Anything I can do to remediate it?

[.ssh]$ lg2 config user.identityFile "~/Documen
ts/.ssh/id_ed25519"
Unable to open repository '%s' '.' [-3] - could
 not find repository from '.'
[.ssh]$ ls
id_ed25519      known_hosts
id_ed25519.pub

You need to call lg2 config from inside a folder that is a git repository, as opposed to inside the .ssh directory.