From: Bernt Hansen <bernt@norang.ca>
To: org-mode <emacs-orgmode@gnu.org>
Subject: Keeping your history for org files
Date: Tue, 01 Apr 2008 12:26:56 -0400 [thread overview]
Message-ID: <87tzilzgkv.fsf@gollum.intra.norang.ca> (raw)
Hi everyone,
Last week I decided I want to keep history of my org-mode file changes.
I've accidentally lost things in the past when editing folded regions
and this gives me a way to get back to the old version without requiring
any extra steps during my normal work.
------------------------------------------------------------------------
* Background
------------------------------------------------------------------------
I keep all of my org files in a single directory tree
(/home/bernt/git/org - or ~/git/org which is an alias to this in the
bash shell)
------------------------------------------------------------------------
* Setting up the git repository
------------------------------------------------------------------------
I set up a git repository for my org files as follows
$ cd ~/git/org
$ git init
I added a .gitignore file so editor backups and export files don't get
in my repository.
,----[ .gitignore]
| *.html
| *~
| .#*
| \#*\#
`----
$ git add .gitignore
$ git commit -m 'Ignore editor backup and export files'
------------------------------------------------------------------------
* 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.
This seems to work great for what I want. If I accidentally clobber
part of a file I can get it back from the git repository.
Here's an example of my current commits made by this setup. Notice it
only creates commits when there are changes to save.
$ git log
,----[ partial git log output ]
| commit a518dc89a51f1740e5c2dfdf11f42ec56b9b3e61
| Author: Bernt Hansen <bernt@norang.ca>
| Date: Tue Apr 1 11:00:01 2008 -0400
|
| Tue Apr 1 11:00:01 EDT 2008
|
| commit eb8f39383ab043b5be948c2ffe5d268bcbe5985f
| Author: Bernt Hansen <bernt@norang.ca>
| Date: Tue Apr 1 10:00:01 2008 -0400
|
| Tue Apr 1 10:00:01 EDT 2008
|
| commit 7a33955d889108746e0abb68dea1a3a310902427
| Author: Bernt Hansen <bernt@norang.ca>
| Date: Mon Mar 31 18:00:02 2008 -0400
|
| Mon Mar 31 18:00:02 EDT 2008
|
| commit eacfe6e2342c89371adb3de5485d6f22271f836c
| Author: Bernt Hansen <bernt@norang.ca>
| Date: Mon Mar 31 16:00:01 2008 -0400
|
| Mon Mar 31 16:00:01 EDT 2008
`----
Regards,
Bernt
next reply other threads:[~2008-04-01 16:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-01 16:26 Bernt Hansen [this message]
2008-04-02 11:40 ` Keeping your history for org files Rainer Stengele
2008-11-15 16:51 ` Peter BARABAS
2008-11-15 18:32 ` Bernt Hansen
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=87tzilzgkv.fsf@gollum.intra.norang.ca \
--to=bernt@norang.ca \
--cc=emacs-orgmode@gnu.org \
/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.