all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Keeping your history for org files
@ 2008-04-01 16:26 Bernt Hansen
  2008-04-02 11:40 ` Rainer Stengele
  0 siblings, 1 reply; 4+ messages in thread
From: Bernt Hansen @ 2008-04-01 16:26 UTC (permalink / raw)
  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 <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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Keeping your history for org files
  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
  0 siblings, 1 reply; 4+ messages in thread
From: Rainer Stengele @ 2008-04-02 11:40 UTC (permalink / raw)
  To: Bernt Hansen; +Cc: org-mode

Hi also,

I also once lost a lot of data in org files due to folding and deleting actions.
I only found out several weeks later!

I have all my org and emacs stuff in a subversion (SVN) repository and was glad therefore to be able to get the data back with the help of old revisions.
I also use SVN to work on my files on three different computers.
Whenever I start orging I update from the repository to get the latest files.
At some computers I also do an automatic save and check in of org buffers - in case I forget to do it manually.

I highly recommend to setup version control for Org files.

Rainer


Bernt Hansen schrieb:
> 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
> 
> 
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Keeping your history for org files
  2008-04-02 11:40 ` Rainer Stengele
@ 2008-11-15 16:51   ` Peter BARABAS
  2008-11-15 18:32     ` Bernt Hansen
  0 siblings, 1 reply; 4+ messages in thread
From: Peter BARABAS @ 2008-11-15 16:51 UTC (permalink / raw)
  To: emacs-orgmode

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.


Regards,
Peter BARABAS.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Keeping your history for org files
  2008-11-15 16:51   ` Peter BARABAS
@ 2008-11-15 18:32     ` Bernt Hansen
  0 siblings, 0 replies; 4+ messages in thread
From: Bernt Hansen @ 2008-11-15 18:32 UTC (permalink / raw)
  To: Peter BARABAS; +Cc: emacs-orgmode

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-11-15 18:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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

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.