cours/sources/clippings, s/informatique, s/obsidian/Sync obsidian with git on iOS using iSH - Obsidian Forum.md
Oscar Plaisant 00850d8482 update
2025-05-08 20:37:56 +02:00

99 lines
5.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
link: https://forum.obsidian.md/t/mobile-sync-with-git-on-ios-for-free-using-ish/20861
author:
- "[[Obsidian Forum]]"
published: 2021-07-14
created: 2025-05-08
tags:
- t/clippings
- s/obsidian
- s/informatique
---
Theres 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.
- p Pros:
- Its free!
- It lets you use *fully-featured git* - the same git that runs on Alpine Linux
- c Cons:
- It requires using the Linux command-line
- There appears to be a *bug* in Obsidian 1.0.3 that doesnt 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 youll 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:
2. Update Alpine repos: `apk update`
3. Install git: `apk add git`
4. Create a directory called `obsidian` in your home directory by running `cd ~ && mkdir obsidian`.
5. Mount your local vault folder into the `obsidian` folder
6. Run `mount -t ios . obsidian`
7. A file picker will show up
8. Choose the folder with your local vault
9. Clone your git repository into `obsidian`
10. Change directory to `obsidian`: `cd obsidian`
11. Delete the `.obsidian` folder: `rm -rf .obsidian`
12. `git clone https://github.com/ForceBru/ObsidianVaultTest .` - use your own repository instead. Dont forget the period `.` - this is what allows you to clone the repo *into the current folder*.
13. (Optional) Run `ls -a` to see whether your files are there
3. In Obsidian
1. Restart Obsidian (might not be necessary)
2. Open the file explorer
3. Currently (Obsidian 1.0.3) its empty (looks like a bug)
4. Tap the “Sort” button (the rightmost one, with up/down arrows)
5. Select any sorting order you like
6. The files should appear
7. Use your Obsidian vault!
4. 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:
4. Set username: `git config user.name ForceBruMobile`
5. Set e-mail address: `git config user.email "ForceBru@users.noreply.github.com"`
6. Add files, commit and push. For example:
7. Add *all* files into the commit: `git add .`
8. Commit: `git commit -m "Commit from mobile"`
9. Push: `git push`
10. This will ask you to enter your username and password
11. Git can use your personal access token to login automatically
12. Thats it! Take a look at [this example commit from iSH](https://github.com/ForceBru/ObsidianVaultTest/commit/f642c3334a870ca8ab2aa1355528403502433b2b)
5. 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
3. Bring remote refs up to date: `git remote update`
4. Check status: `git status`
5. 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
6. Actually update from the remote repo: `git pull`
2. In Obsidian:
1. Go to file explorer
2. If you dont see your new notes, do the sort trick again:
3. Tap the “Sort” button (the rightmost one, with up/down arrows)
4. Select any sorting order you like
5. 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)