From mboxrd@z Thu Jan 1 00:00:00 1970 From: Richard Lawrence Subject: Re: Advice needed: Cant find a decent way to autosync my work TODO org file between laptop and work pc Date: Sat, 24 May 2014 09:49:41 -0700 Message-ID: <87ha4fktp6.fsf@berkeley.edu> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55528) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WoFAP-0007kY-1u for emacs-orgmode@gnu.org; Sat, 24 May 2014 12:51:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WoFAI-0001h8-Rx for emacs-orgmode@gnu.org; Sat, 24 May 2014 12:51:28 -0400 Received: from plane.gmane.org ([80.91.229.3]:46416) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WoFAI-0001gx-Lm for emacs-orgmode@gnu.org; Sat, 24 May 2014 12:51:22 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WoFAH-0003Zq-K0 for emacs-orgmode@gnu.org; Sat, 24 May 2014 18:51:21 +0200 Received: from c-67-164-45-159.hsd1.ca.comcast.net ([67.164.45.159]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 24 May 2014 18:51:21 +0200 Received: from richard.lawrence by c-67-164-45-159.hsd1.ca.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 24 May 2014 18:51:21 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Cc: Xebar Saram Hi Xebar, Xebar Saram writes: > i mainly used git over the last 6 months but that forces me to > pull/commit/push manually each time i add something to either machine and > that is really annoying. plus i get merge conflicts all the time > > I have tried dropbox at the past but again this causes conflicts, > isntreliable to me (on my > linux laptop it doesn't always resume sync after sleep) If neither git nor Dropbox works for you, I'm not sure this will be helpful, but... I personally use git for this. To keep the effort of syncing and merging low, I have a cron job set up to automatically commit in certain repositories containing my Org files every hour. It's just a quick-and-dirty hack, but here it is: #+BEGIN_SRC bash #!/bin/bash # Add org file changes to the repository ROOT=$HOME REPOS="org Documents/philosophy/dissertation Documents/philosophy/teaching Documents/philosophy/reading src/emacs" commit_and_push() { for REPO in $REPOS do echo "Repository: $ROOT/$REPO" cd $ROOT/$REPO if [ ! -d .git ]; then echo "Not a git repository; skipping" continue fi if [ ! -r autocommits ]; then echo "No autocommits file found; skipping" continue fi # Remove deleted files git ls-files --deleted -z | xargs -0 git rm >/dev/null 2>&1 # Add files on whitelist to commit for current branch while read FILE do git add $FILE done < autocommits git commit -m "$(date) from $(hostname) by autocommit.sh" STATUS=$? if [ $STATUS != 0 ]; then echo "git commit failed with exit status $STATUS" fi # Push the current branch # requires branch..remote to be specified in git config # and ideally push.default = tracking git push --porcelain STATUS=$? if [ $STATUS != 0 ]; then echo "git push failed with exit status $STATUS" fi done } pull() { for REPO in $REPOS do echo "Repository: $REPO" cd $ROOT/$REPO git status | grep 'modified:' if [ $? == 0 ]; then echo "modified files present; fetching, but not pulling." CMD="fetch" else CMD="pull" fi git $CMD STATUS=$? if [ $STATUS != 0 ]; then echo "git $CMD failed with exit status $STATUS" fi done } case "$1" in commit) commit_and_push ;; pull) pull ;; *) echo "Usage: $0 {commit|pull}" exit 1 ;; esac exit 0 #+END_SRC This script requires a file called "autocommits" in each repository in $REPOS which is a whitelist of files to autocommit changes in. Most of my Org files are on such a list. I run this from Cron like: #+BEGIN_SRC cron 0 * * * * ~/bin/autocommits.sh commit >/dev/null 2>&1 #+END_SRC To make sure my changes are saved before this script runs, I have in my .emacs: #+BEGIN_SRC elisp (run-at-time "00:59" 3600 'org-save-all-org-buffers) ; cron commits on the hour (add-hook 'before-save-hook 'org-update-all-dblocks) #+END_SRC And finally, to pull the autocommitted changes on a new machine: $ autocommits.sh pull So you still have to manually pull and fix any merge conflicts, but I find that committing often generally keeps the work involved here minimal (because I can't usually work on two machines at once!). Hope that helps! Best, Richard