45

How can I keep my .org files up to date across several computers, perhaps across multiple platforms(linux/windows)?

I could keep all the .org files in git for example, but that would require me to remember to pull and push to keep the repo updated. Could work with a few scripts to automatically handle the files, as I don't have that many.

I could try using dropbox for this as well. I'd assume dropbox syncs the files often enough to not cause problems.

Does org-mode offer any functionality to help with synchronizing the files across multiple locations?

Zavior
  • 591
  • 1
  • 4
  • 7
  • 2
    Does this help? [Putting your org...](http://orgmode.org/worg/org-tutorials/org-vcs.html) – programking Oct 30 '14 at 21:45
  • Dropbox syncs files as soon as they are written. Internally, I believe Dropbox uses a Python script to monitor the directory. – Sean Allred Oct 30 '14 at 22:01
  • If security/privacy is an issue, [SpiderOak](https://spideroak.com/) is also pretty great. – jon Oct 31 '14 at 00:01
  • http://orgmode.org/worg/org-contrib/gsoc2012/student-projects/git-merge-tool/index.html / http://orgmode.org/worg/org-contrib/gsoc2012/student-projects/git-merge-tool/proposal.html mentions an org-file git merge driver, but I can't find any info on how to use it (if it was finished) – unhammer Apr 12 '16 at 16:52
  • Here is an example of how to synchronize folders on different machines using `rsync` through Emacs: https://emacs.stackexchange.com/a/5844/2287 – lawlist Jun 05 '17 at 22:41
  • I am about to try using Tramp for something similar to this. – nroose Jan 30 '19 at 18:16

10 Answers10

11

I use git-annex assistant to sync my org files across my computers and even my phone (a jolla so the linux binary works out of the box but there is also an android version).

It works like dropbox in that whenever you save a file it will try to sync it but it is decentralized and free (as in free speech and free beer).

The setup is straightforward if you know git but you need some time to familiarize yourself with all the options.

You can find more at http://git-annex.branchable.com

razcampagne
  • 111
  • 2
  • Please correct me if I am wrong, but git-annex assistant is a horrible choice. It doesn't check for changes within text files. It also sets the files to 'read-only' every time they sync. – JasoonS Feb 20 '17 at 14:15
9

Org files are just plain text files, so any technique that is able to synchronise plain text files will work fine with org files.

My favourite synchronisation tool is Unison. With the right configuration file, I type

unison org

and Unison will compare files in my ~/org/ directories on both my machines, let me interactively review its actions, then copy the files that need to be copied and invoke an external merge tool for the files that need merging.

jch
  • 5,680
  • 22
  • 39
5

I use Git to synchronize my org-mode files. I have a Bash script that I leave running in the background, which automatically commits the file every minute (by default), and then pushes or pulls as needed.

The pseudo-code version:

  1. Commit local changes and update remotes.
  2. Find local commit with git rev-parse @.
  3. Find remote commit with git rev-parse @{u}.
  4. Find base with git merge-base @ @{u}
  5. If local commit equals remote commit, then we are done; everything is up-to-date.
  6. If local commit equals base, then remote has extra commits, so do git pull.
  7. If remote commit equals base, then local has extra commits, so do git push.
  8. Otherwise, both local and remote has extra commits. My script tries to resolve this automatically (with git pull), but if it can't, will send a bell and exit for the user to fix manually.

Those 8 steps run in a loop, not stopping until I exit manually with C-c, or there is an error.

I use this script on Windows using Cygwin.

Scott Weldon
  • 2,695
  • 1
  • 17
  • 31
  • Is commiting every minute a good idea without a proper commit message? – alper Oct 17 '22 at 10:41
  • @alper Depends on your definition of "good idea", ha. For me "why" something changed is less important than ensuring the changes are synced. I use this primarily for my org-mode todo list, which I update dozens of times a day, so I don't want to take the extra time to come up with a commit message every time I do. (This would land in the top-left of [this xkcd chart](https://xkcd.com/1205/).) Sure, if you're composing a document in Org Mode it'd make sense to commit manually. But for my use case I don't need that, and when I do need more info I just add a comment directly in my org file. – Scott Weldon Oct 21 '22 at 00:34
  • Every minute would be 1440 commits per day. Lets say you work 6 hours per day there will be around 360 commits per day and 129600 commits in a year. Without a proper commit message it will take more time to figure out what you have commited last year nearly ~129600 commits before. Even piping all into `less` consumes long time and when git repo shrinks it will consume more time to pull sync ... – alper Oct 21 '22 at 00:47
4

Org mode does not provide any syncing functionality itself. You would have to rely on a separate application like Dropbox to sync your files. Dropbox syncs not just often, but immediately when files change, so unless you change a file and immediately shut off your computer, you will keep your files in sync.

Ryan
  • 3,989
  • 1
  • 26
  • 49
4

I personally have this problem and have been using copy instead of Dropbox to have my files in sync. (I don't use Dropbox because of privacy issues). Just like Dropbox, Copy offers clients for all the major platforms.

Sometimes I forget to save my org buffers, so I have hacked the following functions to save all org files whenever I save some file. Not a great solution, but it serves my purpose.

(add-hook 'after-save-hook 'org-save-all-org-buffers)

Also, if you hold sensitive data in your org files, I recommend you to take a look at this page. I use org-crypt which is amazing.

Renan Ranelli
  • 1,379
  • 10
  • 17
4

As others have said, Org mode doesn't do anything about this itself (nor should it). So it's basically a matter of finding your preferred file sync solution.

I use Dropbox. It functions without effort on my three platforms (macOS, desktop Linux, Android). Also, the mobile Org client I use, Orgzly, supports it out of the box.

Paul Bissex
  • 833
  • 8
  • 9
3

I use Dropbox to synchronize my main .org files instead of rsync, git or the like because using Dropbox you can also use MobileOrg to see your .org files from your smartphone.

For me this is very easy and it does an awesome job.

itsjeyd
  • 14,586
  • 3
  • 58
  • 87
Rafa de Castro
  • 1,231
  • 10
  • 14
2

I recommend Synchthing https://syncthing.net/

Syncthing is a continuous file synchronization program. It synchronizes files between two or more computers in real time, safely protected from prying eyes. Your data is your data alone and you deserve to choose where it is stored, whether it is shared with some third party, and how it's transmitted over the internet.

user33330
  • 21
  • 1
1

I'm currently using btsync, but there are several open (and more cumbersome) alternatives around. It basically watches the directory and syncs it to all other running devices as soon as they get online. A dropbox without the cloud so to speak. Since it uses distributed hash tables and the torrent protocol firewalls aren't an issue either, and there are mobile clients, too. And it transfers everything encrypted.

Daniel Ziltener
  • 244
  • 1
  • 8
0

Dropbox (or any other cloud storage I guess) is the way to go. In addition, this is really handy to synchronize the Emacs setup in ~/.emacs.d (use mklink on Windows).

Alain
  • 363
  • 2
  • 7