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

**URL:** <https://forum.obsidian.md/t/mobile-sync-with-git-on-ios-for-free-using-ish/20861>\
**Category:** Workflows & Templates\
**Created:** [July 14, 2021, 12:38pm UTC](https://forum.obsidian.md/t/mobile-sync-with-git-on-ios-for-free-using-ish/20861 "2021-07-14T12:38:46Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![ForceBru](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/f/a88e4f/32.png) [@ForceBru](https://forum.obsidian.md/u/ForceBru)\
**Post date:** [July 14, 2021, 12:38pm UTC](https://forum.obsidian.md/t/mobile-sync-with-git-on-ios-for-free-using-ish/20861/1 "2021-07-14T12:38:46Z")

</div>

There’s already a post about syncing with WorkingCopy ([[Mobile] Setting up iOS git-based syncing with mobile app (using Working Copy)](https://forum.obsidian.md/t/mobile-setting-up-ios-git-based-syncing-with-mobile-app-using-working-copy/16499)). However, the ability to push is paid, and it costs a lot, but without this there can be no sync!

I propose to use [iSH](https://ish.app) to sync Obsidian with git.

Pros:

- It’s free!
- It lets you use _fully-featured git_ - the same git that runs on Alpine Linux

Cons:

- It requires using the Linux command-line
- There appears to be a _bug_ in Obsidian 1.0.3 that doesn’t show new files in the file explorer after you pull them from GitHub. This can be easily circumvented by sorting the notes

# Tutorial

Also see [the example repository](https://github.com/ForceBru/ObsidianVaultTest) I created to showcase this method.

Also see “Simpler way” below.

Assuming you have an _existing_ repo on GitHub. You can also create the repo right from iSH - the `git` command you’ll be using is the exact same fully-featured `git` from Alpine Linux.

1. Create a new empty _local_ vault in Obsidian
2. In iSH:
  1. _First-time setup_ - install git:
    1. Update Alpine repos: `apk update`
    2. Install git: `apk add git`

  2. Create a directory called `obsidian` in your home directory by running `cd ~ && mkdir obsidian`.
  3. Mount your local vault folder into the `obsidian` folder
    1. Run `mount -t ios . obsidian`
    2. A file picker will show up
    3. Choose the folder with your local vault

  4. Clone your git repository into `obsidian`
    1. Change directory to `obsidian`: `cd obsidian`
    2. Delete the `.obsidian` folder: `rm -rf .obsidian`
    3. `git clone https://github.com/ForceBru/ObsidianVaultTest .` - use your own repository instead. Don’t forget the period `.` - this is what allows you to clone the repo _into the current folder_.
    4. (Optional) Run `ls -a` to see whether your files are there

  5. In Obsidian
    1. Restart Obsidian (might not be necessary)
    2. Open the file explorer
      1. Currently (Obsidian 1.0.3) it’s empty (looks like a bug)
      2. Tap the “Sort” button (the rightmost one, with up/down arrows)
      3. Select any sorting order you like
      4. The files should appear

    3. Use your Obsidian vault!

3. To **push** your changes, go back to iSH
  1. Change directory to `obsidian` in your home directory: `cd ~/obsidian`
  2. Run `git status` to confirm that there _are_ modified files
  3. _First-time setup_ - tell git who you are:
    1. Set username: `git config user.name ForceBruMobile`
    2. Set e-mail address: `git config user.email "ForceBru@users.noreply.github.com"`

  4. Add files, commit and push. For example:
    1. Add _all_ files into the commit: `git add .`
    2. Commit: `git commit -m "Commit from mobile"`
    3. Push: `git push`
      1. This will ask you to enter your username and password
      2. Git can use your personal access token to login automatically

    4. That’s it! Take a look at [this example commit from iSH](https://github.com/ForceBru/ObsidianVaultTest/commit/f642c3334a870ca8ab2aa1355528403502433b2b)

4. To **pull** changes from GitHub:
  1. In iSH:
    1. Change directory to `obsidian` in your home directory: `cd ~/obsidian`
    2. (Optional) Check whether there is stuff to pull
      1. Bring remote refs up to date: `git remote update`
      2. Check status: `git status`
        1. It should say something like `Your branch is behind 'origin/master' by 2 commits, and can be fast-forwarded` if there is something to be updated

    3. Actually update from the remote repo: `git pull`

  2. In Obsidian:
    1. Go to file explorer
    2. If you don’t see your new notes, do the sort trick again:
      1. Tap the “Sort” button (the rightmost one, with up/down arrows)
      2. Select any sorting order you like
      3. The files should appear

    3. Updates to _existing_ notes seem to be reflected correctly

* * *

# Simpler way

Mount _the entire_ Obsidian folder which contains _all_ your vaults (as opposed to mounting just the vault).

In iSH:

1. Make directory to store Obsidian vaults: `cd ~ && mkdir obsidian`
2. Mount the file provider: `mount -t iOS . obsidian`
3. Choose `On My iDevice` and _select and open the `Obsidian` folder_
4. Change directory to `obsidian`: `cd obsidian`
5. Clone the repo with your vault _right there_: `git clone https://github.com/ForceBru/ObsidianVaultTest`
6. This will create a folder called `ObsidianVaultTest` that will be a git repo and that Obsidian will recognize as a vault

Then open the vault in Obsidian (might need to restart it), edit stuff, then push/pull changes as described in steps 3 and 4 in the original post.

To avoid entering login/password all the time, cache or store your credentials: [Git - Credential Storage](https://git-scm.com/book/en/v2/Git-Tools-Credential-Storage)

---

<div class="post-metadata">

**Author:** ![DummyME](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/d/ba8739/32.png) [@DummyME](https://forum.obsidian.md/u/DummyME)\
**Post date:** [July 15, 2021, 3:36am UTC](https://forum.obsidian.md/t/mobile-sync-with-git-on-ios-for-free-using-ish/20861/2 "2021-07-15T03:36:09Z")

</div>

Requires a manual push pull?  
and is it stored in iCloud or Obsidian app folder?

---

<div class="post-metadata">

**Author:** ![ForceBru](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/f/a88e4f/32.png) [@ForceBru](https://forum.obsidian.md/u/ForceBru)\
**Post date:** [July 15, 2021, 9:39am UTC](https://forum.obsidian.md/t/mobile-sync-with-git-on-ios-for-free-using-ish/20861/3 "2021-07-15T09:39:34Z")

</div>

Yes, pushing and pulling is manual via the command line. The data are stored on your device, but it might be possible to mount the iCloud folder in the same way.

---

<div class="post-metadata">

**Author:** ![DummyME](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/d/ba8739/32.png) [@DummyME](https://forum.obsidian.md/u/DummyME)\
**Post date:** [July 15, 2021, 3:04pm UTC](https://forum.obsidian.md/t/mobile-sync-with-git-on-ios-for-free-using-ish/20861/4 "2021-07-15T15:04:50Z")

</div>

Could there be something done using Shortcuts? Like to run that command from a widget itself?

---

<div class="post-metadata">

**Author:** ![Krafty](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/k/ea666f/32.png) [@Krafty](https://forum.obsidian.md/u/Krafty)\
**Post date:** [July 16, 2021, 5:45pm UTC](https://forum.obsidian.md/t/mobile-sync-with-git-on-ios-for-free-using-ish/20861/5 "2021-07-16T17:45:24Z")

</div>

This is great! Though the `git add .` command is running very slow for me for some reason 🤔

I imagine it is easy to add some simple push and pull scripts to save time.

~/push

```auto
#!/bin/sh
cd ~/obsidian
git add .
git commit -m "Commit from mobile"
git push

```

~/pull

```auto
#!/bin/sh
cd ~/obsidian
git pull

```

---

<div class="post-metadata">

**Author:** ![ForceBru](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/f/a88e4f/32.png) [@ForceBru](https://forum.obsidian.md/u/ForceBru)\
**Post date:** [July 16, 2021, 9:37pm UTC](https://forum.obsidian.md/t/mobile-sync-with-git-on-ios-for-free-using-ish/20861/6 "2021-07-16T21:37:50Z")

</div>

iSH emulates an Intel x86 CPU, so yeah, it can be pretty slow sometimes. It’s indeed possible to add your own scripts - iSH runs real-world Alpine Linux, so it can do basically whatever Alpine can do, except for things restricted by iOS, like USB/Lightning connections.

---

<div class="post-metadata">

**Author:** ![ForceBru](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/f/a88e4f/32.png) [@ForceBru](https://forum.obsidian.md/u/ForceBru)\
**Post date:** [July 16, 2021, 9:40pm UTC](https://forum.obsidian.md/t/mobile-sync-with-git-on-ios-for-free-using-ish/20861/7 "2021-07-16T21:40:32Z")

</div>

I’m using iOS 12.4, so I’m guessing it can’t do much in the Shortcuts department. Not sure about what’s possible in more recent versions of iOS.

---

<div class="post-metadata">

**Author:** ![DummyME](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/d/ba8739/32.png) [@DummyME](https://forum.obsidian.md/u/DummyME)\
**Post date:** [July 18, 2021, 7:36pm UTC](https://forum.obsidian.md/t/mobile-sync-with-git-on-ios-for-free-using-ish/20861/8 "2021-07-18T19:36:28Z")

</div>

The `cd` Command should include the vault name too right? Since obsidian will not have any git. At least it throws an error for me. `git add .` is way too slow for me as well. ☹

---

<div class="post-metadata">

**Author:** ![DummyME](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/d/ba8739/32.png) [@DummyME](https://forum.obsidian.md/u/DummyME)\
**Post date:** [July 18, 2021, 7:49pm UTC](https://forum.obsidian.md/t/mobile-sync-with-git-on-ios-for-free-using-ish/20861/9 "2021-07-18T19:49:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![DummyME](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/d/ba8739/32.png) [@DummyME](https://forum.obsidian.md/u/DummyME)\
**Post date:** [July 18, 2021, 8:32pm UTC](https://forum.obsidian.md/t/mobile-sync-with-git-on-ios-for-free-using-ish/20861/10 "2021-07-18T20:32:02Z")

</div>

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😕

---

<div class="post-metadata">

**Author:** ![yvonnezed](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/y/e19adc/32.png) [@yvonnezed](https://forum.obsidian.md/u/yvonnezed)\
**Post date:** [July 18, 2021, 9:10pm UTC](https://forum.obsidian.md/t/mobile-sync-with-git-on-ios-for-free-using-ish/20861/11 "2021-07-18T21:10:10Z")

</div>

An alternative worth playing with might be a-Shell, [‎a-Shell on the App Store](https://apps.apple.com/au/app/a-shell/id1473805438)

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

---

<div class="post-metadata">

**Author:** ![DummyME](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/d/ba8739/32.png) [@DummyME](https://forum.obsidian.md/u/DummyME)\
**Post date:** [July 19, 2021, 2:39pm UTC](https://forum.obsidian.md/t/mobile-sync-with-git-on-ios-for-free-using-ish/20861/12 "2021-07-19T14:39:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ForceBru](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/f/a88e4f/32.png) [@ForceBru](https://forum.obsidian.md/u/ForceBru)\
**Post date:** [July 20, 2021, 9:19pm UTC](https://forum.obsidian.md/t/mobile-sync-with-git-on-ios-for-free-using-ish/20861/13 "2021-07-20T21:19:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![DummyME](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/d/ba8739/32.png) [@DummyME](https://forum.obsidian.md/u/DummyME)\
**Post date:** [July 21, 2021, 8:34pm UTC](https://forum.obsidian.md/t/mobile-sync-with-git-on-ios-for-free-using-ish/20861/14 "2021-07-21T20:34:05Z")

</div>

Yes. That’s exactly what I am exploiting for now. 😁  
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. 🤞

---

<div class="post-metadata">

**Author:** ![Atlas](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/a/0ea827/32.png) [@Atlas](https://forum.obsidian.md/u/Atlas)\
**Post date:** [July 26, 2021, 3:10am UTC](https://forum.obsidian.md/t/mobile-sync-with-git-on-ios-for-free-using-ish/20861/15 "2021-07-26T03:10:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![andrezgz](https://forum.obsidian.md/user_avatar/forum.obsidian.md/andrezgz/32/7334_2.png) [@andrezgz](https://forum.obsidian.md/u/andrezgz)\
**Post date:** [July 26, 2021, 9:28pm UTC](https://forum.obsidian.md/t/mobile-sync-with-git-on-ios-for-free-using-ish/20861/16 "2021-07-26T21:28:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![evergreensnow](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/e/ec9cab/32.png) [@evergreensnow](https://forum.obsidian.md/u/evergreensnow)\
**Post date:** [July 27, 2021, 3:32am UTC](https://forum.obsidian.md/t/mobile-sync-with-git-on-ios-for-free-using-ish/20861/17 "2021-07-27T03:32:20Z")

</div>

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](https://gnupg.org/) 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)

```auto
#!/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

```auto
#!/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 😄

---

<div class="post-metadata">

**Author:** ![yvonnezed](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/y/e19adc/32.png) [@yvonnezed](https://forum.obsidian.md/u/yvonnezed)\
**Post date:** [July 27, 2021, 7:15am UTC](https://forum.obsidian.md/t/mobile-sync-with-git-on-ios-for-free-using-ish/20861/18 "2021-07-27T07:15:25Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Atlas](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/a/0ea827/32.png) [@Atlas](https://forum.obsidian.md/u/Atlas)\
**Post date:** [July 27, 2021, 2:22pm UTC](https://forum.obsidian.md/t/mobile-sync-with-git-on-ios-for-free-using-ish/20861/19 "2021-07-27T14:22:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![goncalvesjoao](https://forum.obsidian.md/user_avatar/forum.obsidian.md/goncalvesjoao/32/20270_2.png) [@goncalvesjoao](https://forum.obsidian.md/u/goncalvesjoao)\
**Post date:** [September 28, 2021, 3:24pm UTC](https://forum.obsidian.md/t/mobile-sync-with-git-on-ios-for-free-using-ish/20861/20 "2021-09-28T15:24:14Z")

</div>

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.

> <https://github.com/ish-app/ish/pull/543#issuecomment-565732659>
>
> I continued working on this. I added file coordination for regular files and rem…oved the \`iosfs\_mount\_data\` function by calling the ui functions in \`iosfs\_mount\`.
> 
> I did a lot of testing with \`git\` in a mounted folder from Working Copy. I noticed that \`git status\` can be quit slow even with mid-size repositories because git will check every file in the repository and each of the coordinator calls slows down the process. That's why I added a second filesystem: \`ios-unsafe\`. That one will simply make sure that the correct permissions for the security scope are requested but the filecoordinators are not used at all. In case of Working Copy, this works very well but there are probably apps which can have a problem with that (that's why I called in \`ios-UNSAFE\`).
> 
> Therefore, this pull request now adds the following two commands:
> 
> \`\`\`sh
> mount -t ios website /mnt/website
> mount -t ios-unsafe website /mnt/website
> \`\`\`
> 
> Finally, someone with more experience in async programming in objective-c should have a look at the usage of mutexes in \`iosfs\_open\`. It does work but I do not know if there is a better/more elegant way of doing this.

Use:

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

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

Warm hug!

[Next page](https://forum.obsidian.md/t/mobile-sync-with-git-on-ios-for-free-using-ish/20861.md?page=2)
