all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Bernt Hansen <bernt@norang.ca>
To: Peter BARABAS <peter.barabas+orgmode@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Keeping your history for org files
Date: Sat, 15 Nov 2008 13:32:52 -0500	[thread overview]
Message-ID: <878wrkj0vf.fsf@gollum.intra.norang.ca> (raw)
In-Reply-To: <loom.20081115T164658-61@post.gmane.org> (Peter BARABAS's message of "Sat\, 15 Nov 2008 16\:51\:45 +0000 \(UTC\)")

Peter BARABAS <peter.barabas+orgmode@gmail.com> writes:

> Rainer Stengele <rainer.stengele <at> diplan.de> writes:
>
> Hello,
>
>
>> > 
>> > ------------------------------------------------------------------------
>> > * Creating commits automatically
>> > ------------------------------------------------------------------------
>> > 
>> > Then I added a cron job on my workstation which commits changes to the
>> > repository automagically.  I decided commits once per hour is enough for
>> > me so I added the following crontab entry:
>> > 
>> > $ crontab -e
>> > 
>> > ,----[ My crontab entry ]
>> > | 0 * * * * cd ~/git/org && git add . && git commit -m "$(date)" >/dev/null
>> > `----
>> > 
>> > and I'm done.  This picks up all my .org and .org_archive files and
>> > tracks changes hourly.
>> > 
>> > If I change a file a new commit gets created on the next hour.  If
>> > nothing changes no commit is created since there is nothing to add.
>> > 
>
> I'm using a similar setup, but with a hook:
>
> (defun git-commit ()
>   (when (eq major-mode 'org-mode)
>     (shell-command "git commit -a -m 'Auto commit.'")))
>
> (add-hook 'after-save-hook 'git-commit)
>
> This way, after I save the file it gets commited.

And I'm using a similar setup to the hourly commit cron job of Rainer's
but with the following script so it removes deleted files too.  This
works over multiple org repositories.

,----[ org-git-sync.sh ]
| #!/bin/sh
| # Add org file changes to the repository
| REPOS="org doc.norang.ca www.norang.ca"
| 
| for REPO in $REPOS
| do
|     echo "Repository: $REPO"
|     cd ~/git/$REPO
|     # Remove deleted files
|     git ls-files --deleted -z | xargs -0 git rm >/dev/null 2>&1
|     # Add new files
|     git add . >/dev/null 2>&1
|     git commit -m "$(date)"
| done
`----

,----[ crontab entry ]
| 0 * * * * ~/bin/org-git-sync.sh >/dev/null
`----

If I want to manually update I just run the org-git-sync.sh script at
the shell prompt.  Usually I do that when moving files to/from my laptop
- so I commit all the changes to the repos and then push/pull the
commits.

I've also added a .gitignore file to skip files created by exporting

,----[ .gitignore ]
| *.html
| *~
| .#*
| \#*\#
| *.txt
| *.tex
| *.aux
| *.dvi
| *.log
| *.out
| *.ics
| *.pdf
`----

so files created by exporting are not automatically added to the repo.
I can still explicitly add .pdf files as attachments if necessary so
that they become tracked.

-Bernt

      reply	other threads:[~2008-11-15 18:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-01 16:26 Keeping your history for org files Bernt Hansen
2008-04-02 11:40 ` Rainer Stengele
2008-11-15 16:51   ` Peter BARABAS
2008-11-15 18:32     ` Bernt Hansen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878wrkj0vf.fsf@gollum.intra.norang.ca \
    --to=bernt@norang.ca \
    --cc=emacs-orgmode@gnu.org \
    --cc=peter.barabas+orgmode@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.