* Re: Advice needed: Cant find a decent way to autosync my work TODO org file between laptop and work pc
2014-05-24 5:11 Advice needed: Cant find a decent way to autosync my work TODO org file between laptop and work pc Xebar Saram
@ 2014-05-24 16:49 ` Richard Lawrence
[not found] ` <CAHxk2pAX=dM_iAJEpTUaeYjPKVm8wELYBgkHZd=cPK__KPmDBw@mail.gmail.com>
2014-05-24 22:54 ` Ken Mankoff
` (2 subsequent siblings)
3 siblings, 1 reply; 9+ messages in thread
From: Richard Lawrence @ 2014-05-24 16:49 UTC (permalink / raw
To: emacs-orgmode; +Cc: Xebar Saram
Hi Xebar,
Xebar Saram <zeltakc@gmail.com> 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.<name>.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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Advice needed: Cant find a decent way to autosync my work TODO org file between laptop and work pc
2014-05-24 5:11 Advice needed: Cant find a decent way to autosync my work TODO org file between laptop and work pc Xebar Saram
2014-05-24 16:49 ` Richard Lawrence
@ 2014-05-24 22:54 ` Ken Mankoff
[not found] ` <CAHxk2pAR-8jAdtS1BdxxsCtfHo--km2HDhaWVQmA8RfcB+kKJQ@mail.gmail.com>
2014-05-25 12:13 ` Josh Berry
2014-05-26 18:08 ` Thierry Banel
3 siblings, 1 reply; 9+ messages in thread
From: Ken Mankoff @ 2014-05-24 22:54 UTC (permalink / raw
To: Xebar Saram; +Cc: org mode
Do you have auto-revert enabled for that file? At the top of a
dropbox-shared Org file I have this:
# -*- coding: utf-8; eval: (auto-revert-mode 1); -*-
I still find it a bit buggy, and also have this code snippet which I
execute whenever I begin editing in that Org file. I also try to
remember to save it when done.
#+BEGIN_SRC emacs-lisp :results none
(revert-buffer nil t)
#+END_SRC
-k.
On 2014-05-24 at 01:11, Xebar Saram <zeltakc@gmail.com> wrote:
> Hi all
>
> i need to sync my main work TODO org file between my work PC and laptop i
> carry around on work related trips and when im at home. i have tried
> several methods buy really none of them work.
>
> 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)
>
> I am using linux (arch linux on laptop and debian on work PC to be precise)
>
> Also i use mobileorg on phones/tablets which works with various levels of
> success :)
>
> any advice would be hugely appreciated!
>
> thanks alot
>
> Z
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Advice needed: Cant find a decent way to autosync my work TODO org file between laptop and work pc
2014-05-24 5:11 Advice needed: Cant find a decent way to autosync my work TODO org file between laptop and work pc Xebar Saram
2014-05-24 16:49 ` Richard Lawrence
2014-05-24 22:54 ` Ken Mankoff
@ 2014-05-25 12:13 ` Josh Berry
2014-05-26 18:08 ` Thierry Banel
3 siblings, 0 replies; 9+ messages in thread
From: Josh Berry @ 2014-05-25 12:13 UTC (permalink / raw
To: Xebar Saram; +Cc: org mode
[-- Attachment #1: Type: text/plain, Size: 1036 bytes --]
On Sat, May 24, 2014 at 1:11 AM, Xebar Saram <zeltakc@gmail.com> wrote:
> need to sync my main work TODO org file between my work PC and laptop i
> carry around on work related trips and when im at home. i have tried
> several methods buy really none of them work.
>
> 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 can't really help for the other items too easily, but have you tried
*not* syncing edits between a single files? This would at least stop the
merge conflicts.
That is, if you had two sets of all of your .org files, one under
"desktop/" and the other under "laptop/", then you could setup a basic hook
in git that pushes/pulls on every change. I believe org is good with the
refile commands that moving between the flies shouldn't be that much of a
burden, if you do that often. Otherwise, things definitely work well for
agenda mode and such.
-josh
[-- Attachment #2: Type: text/html, Size: 1489 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Advice needed: Cant find a decent way to autosync my work TODO org file between laptop and work pc
2014-05-24 5:11 Advice needed: Cant find a decent way to autosync my work TODO org file between laptop and work pc Xebar Saram
` (2 preceding siblings ...)
2014-05-25 12:13 ` Josh Berry
@ 2014-05-26 18:08 ` Thierry Banel
3 siblings, 0 replies; 9+ messages in thread
From: Thierry Banel @ 2014-05-26 18:08 UTC (permalink / raw
To: emacs-orgmode
You can try GIT-ANNEX
https://git-annex.branchable.com/
It is a synchronizer built on top of GIT
Le 24/05/2014 07:11, Xebar Saram a écrit :
> Hi all
>
> i need to sync my main work TODO org file between my work PC and
> laptop i carry around on work related trips and when im at home. i
> have tried several methods buy really none of them work.
>
> 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, isnt
> reliable to me (on my linux laptop it doesn't always resume sync after
> sleep)
>
> I am using linux (arch linux on laptop and debian on work PC to be
> precise)
>
> Also i use mobileorg on phones/tablets which works with various levels
> of success :)
>
> any advice would be hugely appreciated!
>
> thanks alot
>
> Z
^ permalink raw reply [flat|nested] 9+ messages in thread