[Mobile] Sync with git on iOS for free using iSH

How can I run the script? I am getting permission denied.

Okay.
Sadly, it worked for a dummy vault, but as I introduced by own vault, it took ages to execute git add . and simply gets stuck despite keeping the app open forever. I haven’t synced .obsidian folder, only edited one test line in a single MD file. And still I am not able to commit😕

An alternative worth playing with might be a-Shell, ‎a-Shell on the App Store

It’s not as full featured as a shell, but it’s got more native bells and whistles including Shortcuts support.

The command to play with is lg2. It’s a work in progress, but it’s usable and a lot faster than iSH

1 Like

Also, I got into thinking. If working copy free version can sync a folder into obsidian folder and pull and commit, why not use it for everything except push(paid).
Then simply mount the working copy folder in ish or anything and git push!

Because, the add command etc are a lot slower in iSH.

Edit: It works!!
Everything is managed in WorkingCopy. iSH is utilised only for git push
Maybe a super noob manoeuvre. :sweat_smile:

2 Likes

That’s pretty cool, actually: WorkingCopy has great GUI, but pushing is paid, while iSH lets you push for free!

Yes. That’s exactly what I am exploiting for now. :grin:
Even had shortcuts. Pulls when I start obsidian, and commits when I exit obsidian.

Later when I leave ipad, I open ISH and git push. :crossed_fingers:

Do you mind sharing the shortcut or the commands in a-shell? I find myself not so familiar with shell commands :dizzy_face:. Thanks!

1 Like

How did you manage to configure Working Copy (free version) to sync a repo into obsidian folder? Can you detail the specific steps, please? :pleading_face:

I strongly dislike the idea of having my notes unencrypted on a hosting service like github so I extended the idea to support end-to-end symmetric AES256 encryption using gnupg on iSH. As the encryption is open source and cross platform you can decrypt your notes anywhere.

Steps:

  1. Make a folders /obsidian and initialize a git repository. This will be a local git repo for rollbacks (see why it is needed later).
  2. Make a subfolder /obsidian/vaults. Mount your ios obsidian folder here. Make sure to delete the .git file so the folder is staged correctly.
  3. Make a folder /syncrepo. This is the repo that pushes/pulls encrypted files to/from the remote.
  4. Initialize a repository in /syncrepo and connect it to your chosen remote repository.

Encryption is done using tar to compress the vaults folder into a single file, and then using gnupg to encrypt the file. As pulling involves overwriting parts of you existing vault, the local repository lets you rollback in case of an accidental pull.

  1. Make sure to install gnupg using apk add gnupg.
  2. Add the push/pull scripts to your root directory.

NOTE: Replace *** with your passphrase in scripts.


Pull script (~/pull)

#!/bin/sh

cd ~/obsidian
git add .
git commit -m "Save before pull"
echo "saved state before pull"

cd ~/syncrepo
git pull
cd ~
echo "pulled repo"

gpg -d --batch --cipher-algo AES256 --passphrase ****** -o - syncrepo/obsidianfile | tar -xzvf -
echo "uncompressed and decrypted"

Push script

#!/bin/sh

cd ~/obsidian
git add .
git commit -m "Save before Push"
echo "saved state before push"
cd ~

tar -czvf - obsidian/vaults | gpg -c --batch --cipher-algo AES256 --yes --passphrase ******* -o syncrepo/obsidianfile

echo "compressed and encrypted"

cd ~/syncrepo
git add .
git commit -m "Commit from Mobile"
git push
cd ~
echo "pushed to remote"
  1. Set both files to run as scripts chmod +x ./pull (and for ./push)
  2. Push/pull whatever content you please :smile:
3 Likes

It’s actually pretty similar to the instructions above for iSH. the difference is that instead of git, the command is lg2. Also, instead of using mount to mount the file provider, the command is pickFolder to create what aShell calls a bookmark. then it’s jump bookmarkname to get into the folder.

Try help at the prompt to get a list of all the aShell specific commands.

As for the shortcut, it depends on what you want it to do. You just use the action to give aShell commands, make sure the first command in the list is to jump into your repo folder and then lg2 push or lg2 add or whatever.

2 Likes

Thank you! I succeeded! The only flaw is that a-Shell must show up after pushed XD

Guys, thank you so much for this tutorial!

I wanna contribute too and my finding is that the developers of iSH created a new filesystem that allow git add . to not be so slow.

Use:

#!/bin/sh
mount -t ios-unsafe . obsidian

and your git status and git add commands should start to run smoothly.

Warm hug!

5 Likes

@DummyME … I tried, but could not make this work. I cannot find / mount the right folder in ish where I can do the push.
Could you pls. provide some more details?

UPDATE: When I use “Setup synced directory” at least I can see a folder to mount … But according to the documentation this seems an not so efficient and obsolete option. When I use “Link external directory” I don’t see any folder to mount.

Update II: found the answer myself: In working copy you have the option for the project where to store the .git - it has to be “Application”. Then I choose “Link external directory” in working copy. Then I can mount the obsidian folder and .git will be in there.

Yes, either you make .git into the application folder or push/pull in WorkiingCopy directory!
I used to push and pull using the Working Copy directory itself.

Also, I would suggest using a-shell over iSH. iSH is pretty slow.
a-shell is quite fast and you can have shortcuts as well!!

I try to do a shortcut in a-shell for mount obsidian vault folder, and commit and push changes, but it seems pickFolder can not put into shortcuts, I should pickFolder in a-shell, and run the shortcut, but when I relaunch a-shell, I need pickFolder again, could you help me?

You need to use jump followed by the bookmark name.

thanks, it works.

would you mind sharing the shortcut? :slight_smile:

It works like a charm with Obsidian Git plugin + iSH

You can do all the git commands right from your Obsidian app on iPhone

2 Likes

Thanks!