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

can you explain a bit more?

the steps

no , eveything was fine but some error came

The error we were getting stems from the fact that that the location of the public key file changed. When lg2 looks for it in the path supplied by user.identityFile, it can’t find it because a-shell changed the layout of their files in a recent update (I think) and the .ssh folder has a different absolute path than before.

You can verify this by going to your vault in a-shell and running lg2 config user.identityFile to see the path lg2 expects the public key to be in. When you run the commands you asked about, pwd -P will return the actual absolute path path of the .ssh folder. It’ll be different from the expected one from earlier (and thus the error).

Here’s what each command does:

  • cd is just to get back to the root(?) directory (might be redundant depending on what your working directory is)
  • cd .ssh is to get into the .ssh folder, where the SSH key files are stored
  • pwd -P returns the absolute path of the current working directory
1 Like

You are a genius man.

Hi, one thing I want to add is, when you setup the user.identityFile, the shell suggest a wrong path like lg2 config user.identityFile '/var/mobile/Containers/.../.ssh/id_ed25519'

But ios doesn’t have access to directly /var/.. dir so it prevent to access the git repo later.

so you need to add “/private” to the path of your ssh files to configure it properly.

e.g)

lg2 config user.identityFile '/private/var/mobile/Containers/Data/.../.ssh/id_ed25519'

ok as siris mentions, a-shell changes its directory after some amount of time (maybe related to iPhone reboot?)

so I just removed the user.identityFile config and let the terminal ask “Consider…” again to get a new path.

To remove the old user.identityFile config I just manually edit the config file by vim ./git/config
Who knows better command, just let me know :slight_smile:

I have updated A-Shell Mini about 4-5 times since my first post on this thread and never seen any changes.

I use Taio to edit the config file, if needed. See above:

Use:

lg2 config user.identityFile “~/Documents/.ssh/id_ed25519”

it works great on my end.

1 Like

I’ve encountered this issue three times now, starting in mid-January. Two times it was immediately after updating a-Shell. I guess a-Shell Mini is different.

The one other time, I’m not sure what the cause was. It might have been after an iOS update (and subsequent restart) as @ruucm suggested.

@snqyz, this solution is awesome! lg2 config user.identityFile ~/Documents/.ssh/id_ed25519 is way more efficient than having to go through and re-set the path every so often. Thanks a bunch!

On an unrelated note, I didn’t know there was another guide for how to use a-Shell and Obsidian together. The other one was posted months before this one, and I researched pretty thoroughly in making mine so I’m surprised I didn’t run into it sooner. It would have been a big help.

1 Like

I don’t know. I used the newer id_ecdsa Auth method and A-Shell mini and never updated iOS itself.

I didn’t know about that tut either. What the guy says – “If you end up with merge conflicts you will need to manually resolve them using lg2 . This can be tricky because it diverges from git sometimes, and I found the documentation sparse” – is true; so instead of using the command line to deal with merge conflicts, I usually used Checkout or lately the GUI of the aforementioned GitViewer app.

I have a large repo and .git folder (mainly because of many regex changes made on PC*), so I sometimes have memory issues on iPad. I rerun the shortcut after closing up some apps, or again, enter GitViewer and push with that (the add-commit part is always done, it’s just the pushing that aborts on memory overload in A-Shell).

* I intend to upload a clean Obsidian vault to another Git repo and start with a leaner .git afresh, once I’m done with all the regex cleaning jobs (I can still go back to older versions of files on earlier repos and pull them down manually).
This is why I don’t use the automation of Obsidian Git either; no need to clutter up my git history with all those commits.

Hi everyone, thank you for these super useful tips!

I’m having a different type of issue: I managed to setup everything up to the point where I need to pull the remote repo locally. When I run lg2 pull origin, a litany of “Received x/N objects (y) in k” prints (as it should when pulling from the remote repo), but at the very end a memory error of some kind occurs: Bad news: failed to mmap. Could not write data: Cannot allocate memory and the process ends. Someone has an idea of what’s going on? Cheers!

It might be a big repo, or an older model device?

No need to look on the net anywhere, there is no fix for it written up.
All you need to do is close running apps and try again until the job is done (you only need to clone once anyway).

If you cannot do it through a-shell, try doing it with GitViewer (it can access any folder) or with Working Copy (but you need to copy your repo over to Obsidian’s folder).

Update - I ended up using github for a safe 1-way sync from my desktop, and the plugin remotely-save + dropbox to actually sync my stuff. I made the mobile swipe-down shorcut be the sync trigger, and it works very well for me! Only issue: if I delete a file on my desktop (where the plugin is not setup, there only dropbox works for synchronisation), the file is re-created as soon as I sync with my mobile (if I delete it on my mobile, where the plugin is setup, it is deleted for good).

@snqyz you legend.

the Application Id is changing quite often so after a few successes git pull or push authentication stopped with the error “Unable to open public key file”.

so we definitely need the not changing relative path like you mentioned.

lg2 config user.identityFile "~/Documents/.ssh/id_ed25519"
lg2 config user.password ""

A bit technical and essentially entails creating a new repo, git init and entering some code (on both sides – desktop and mobile) but on this website there are some good ideas on how to optimize memory consumption.

  • It is always worthwhile to search other sites (StackOverflow, for one) on the same topics to see how much leverage one has.

Basically, on both ends you need to copy-paste this into the git config files:

[core]
    packedGitLimit = 128m
    packedGitWindowSize = 128m

[pack]
    deltaCacheSize = 128m
    packSizeLimit = 128m
    windowMemory = 128m
  • The 128m’s are not written in stone, on other sites they go lower at 100m on all and generally needs tweaking to one’s needs.

My experience using this is that the going on iOS is a bit slower than before but mind you, I have a fresh repo and new config, so I no longer have pack files nearly 1GB large, so it’s early going and mostly I’m putting this up for others to engage in testing this.

Hey ,can we pull and push every time without entering password (token) is it possible?

Are you using A-Shell with git protocol? Read the first few posts again.

Hello

I got a problem
Failed to authentificate SSH session: Unable to open public key file when i do lg2 pull origin

I don’t know if it’s a configuration of my GitHub problem …
or another thing …

I’m here

Create local repo:

  1. Go back to the obsidian folder with jump obsidian
  2. Create a subfolder for your vault with mkdir VAULT-NAME, then do the following commands to clone your vault:
  • cd VAULT-NAME
  • lg2 init .
  • lg2 remote add origin [email protected]:USERNAME/REPO-NAME.git
  • lg2 pull origin

You need a key generated and the public pair needs to be added to GitHub (go into your repo, settings and deploy keys and add).

There is no need to mkdir anything, by the way. Once you pull your .git into your directory, it will have taken care of the folder name which you can rename (and delete .git from foldername). I don’t like to see and do unnecessary extra steps . – Just my two cents.

1 Like