From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bernt Hansen Subject: Keeping your history for org files Date: Tue, 01 Apr 2008 12:26:56 -0400 Message-ID: <87tzilzgkv.fsf@gollum.intra.norang.ca> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JgjKB-0003nU-C5 for emacs-orgmode@gnu.org; Tue, 01 Apr 2008 12:27:03 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JgjKA-0003n9-86 for emacs-orgmode@gnu.org; Tue, 01 Apr 2008 12:27:02 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JgjKA-0003n6-1m for emacs-orgmode@gnu.org; Tue, 01 Apr 2008 12:27:02 -0400 Received: from mho-02-bos.mailhop.org ([63.208.196.179]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JgjK9-0003Kh-TM for emacs-orgmode@gnu.org; Tue, 01 Apr 2008 12:27:02 -0400 Received: from cpe000102d0fe75-cm0012256ecbde.cpe.net.cable.rogers.com ([99.239.148.180] helo=mail.norang.ca) by mho-02-bos.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.68) (envelope-from ) id 1JgjK7-0007a8-2V for emacs-orgmode@gnu.org; Tue, 01 Apr 2008 16:26:59 +0000 Received: from gollum.intra.norang.ca (gollum.intra.norang.ca [192.168.1.5]) by mail.norang.ca (8.13.8/8.13.8/Debian-3) with ESMTP id m31GQu2t026524 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Tue, 1 Apr 2008 12:26:57 -0400 Received: from gollum.intra.norang.ca (localhost [127.0.0.1]) by gollum.intra.norang.ca (8.14.2/8.14.2/Debian-1) with ESMTP id m31GQuiq016538 for ; Tue, 1 Apr 2008 12:26:56 -0400 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: org-mode 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 | Date: Tue Apr 1 11:00:01 2008 -0400 | | Tue Apr 1 11:00:01 EDT 2008 | | commit eb8f39383ab043b5be948c2ffe5d268bcbe5985f | Author: Bernt Hansen | Date: Tue Apr 1 10:00:01 2008 -0400 | | Tue Apr 1 10:00:01 EDT 2008 | | commit 7a33955d889108746e0abb68dea1a3a310902427 | Author: Bernt Hansen | Date: Mon Mar 31 18:00:02 2008 -0400 | | Mon Mar 31 18:00:02 EDT 2008 | | commit eacfe6e2342c89371adb3de5485d6f22271f836c | Author: Bernt Hansen | Date: Mon Mar 31 16:00:01 2008 -0400 | | Mon Mar 31 16:00:01 EDT 2008 `---- Regards, Bernt