[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Orgmode] Re: Keeping your history for org files
From: |
Bernt Hansen |
Subject: |
[Orgmode] Re: Keeping your history for org files |
Date: |
Sat, 15 Nov 2008 13:32:52 -0500 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) |
Peter BARABAS <address@hidden> 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