How to sync LogSeq via Git across devices and platforms
In this post I will show you how I sync my LogSeq graph between my Mac, Windows PC, iPhone and iPad using my own git server, the Working Copy app for iOS and personal automations in Shortcuts.
This way I can use my notes offline whenever needed and sync them between all of my devices and across platforms without a third party involved. My notes remain on devices owned and managed by me at all times and I don't have to worry about anybody else potentially having access to them.
If you need extra layers of security, you could also think about encrypting your graph with the built-in functionality within LogSeq. This is however still an experimental feature.
What you will need
- A machine to serve as the git host - e.g. an old PC that's always running, a home server or a Raspberry Pi.
- The LogSeq app installed on the devices you want to use - in this guide I'm using a Mac and an iPhone.
- The pro version of Working Copy for iOS
- Two automations using the Shortcuts app on iOS
These are the steps you need to take with a brand new setup
- Install LogSeq on a PC/Mac and create a new graph in a folder of your choice.
- Optional: Activate automatic commits in Settings → Version control → Enable Git auto commit. This initializes the folder as a git repository and automatically commits your work every 60 seconds by default (I've set this to 300 seconds).
Otherwise: Initialize the folder manually by opening a Terminal window on your Mac, cd into the folder that holds your graph and typing
- Set up a new, empty git repository on your server. For example using this guide if you run Linux: How to set up a private git server on a vps
- Open a Terminal window on your Mac and cd into the folder that holds your LogSeq graph. Add the remote from step 3 to your local repository:
git remote add origin <remote-url>
- Push your graph to the remote:
git push -u origin main
- Install the LogSeq mobile app on your phone and create a new folder in the LogSeq directory under "On My iPhone". In my example I have created a folder called "notes":
- Install the Working Copy app on your phone, unlock the pro version and add the directory from step 6 via the “link external directory” option.
- Add the same url you used in step 4 as a remote for the directory in Working Copy.
- Set up automations in the Shortcuts app to automatically pull and push changes when you open or close the LogSeq app.
This setup works really well if you only work on one device at a time. If you use multiple devices simultaneously you might run into git conflicts and will need to resolve them manually.
If you want to automate this further you could also use git hooks to push/pull before or after each commit as described in this post. This would completely automate your setup and you wouldn't need to do any git operations any more unless you have conflicts.