emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Keeping org files under git - trimming the repository
@ 2009-08-04 12:10 Ben Alexander
  2009-08-04 12:26 ` Benjamin Andresen
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Ben Alexander @ 2009-08-04 12:10 UTC (permalink / raw)
  To: org-mode Mailinglist

Hello all.
This is really more of a git question, but I keep my org file stored  
under git and I've seen other people on this list speak of doing the  
same.  Different people cite different benefits:

+ keeping home and work copies of todo.org in sync
+ storing todo.org on a USB stick for transport instead of using a  
network
+ safety while editing. If a slip of the fingers hits C-k on a folded  
line and you don't notice it for a long time, git allows you to find  
when that happen (git blame) and 'cherry-pick' a patch to bring the  
lost subtree forward in time.

I don't really know how to do any of  these things in git, but that's  
what you all say :-)

About a year ago, I decided to learn how to write "macros" in lisp and  
started by teaching myself about the after-save-hook.  I added a hook  
to auto commit every time I saved any org file.  My simple, small text  
file of todo items is now a giant git repository.

At last a question or two: Does this happen to you? What do you do?   
What new git command do I need to learn in order to do it?

Is there some way to clone my git repo onto my USB stick, but make it  
a subset instead of the whole thing?  That would be useful for me to  
learn for other git projects!

Just curious!

(and thanks to you all for the interesting discussions and excellent  
tool!)

-Ben

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

* Re: Keeping org files under git - trimming the repository
  2009-08-04 12:10 Keeping org files under git - trimming the repository Ben Alexander
@ 2009-08-04 12:26 ` Benjamin Andresen
  2009-08-04 13:31 ` Matt Lundin
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Benjamin Andresen @ 2009-08-04 12:26 UTC (permalink / raw)
  To: org-mode Mailinglist

Hey Ben,

Ben Alexander <bva@alexanderonline.org> writes:

>  Different people cite different benefits:
> + safety while editing. If a slip of the fingers hits C-k on a folded
> line and you don't notice it for a long time, git allows you to find
> when that happen (git blame) and 'cherry-pick' a patch to bring the
> lost subtree forward in time.

That's the reason I do it.

I have my main laptop where I spend 90% of my time on so syncing is not
the issue for me.

>  I added a hook to auto commit every time I saved any org file. My
> simple, small text file of todo items is now a giant git repository.
>
> At last a question or two: Does this happen to you? What do you do?
> What new git command do I need to learn in order to do it?

I don't quite understand the first question. But I give a shot on the
second question (Hopefully I understood it correctly.):

My setup is that I keep my org files in ~/Org, I then launch a script at
the start of my login session that automatically commits every change
done to a ".org*" file. (Everything else is git-ignored.)

This is the file that does all the magic. ;-)
,----[ org-autocommitd ]
| #!/bin/zsh
| 
| WATCHDIR=~/Org
| cd $WATCHDIR
| 
| inotifywait -m --format '%f' -e close_write $WATCHDIR | \
| while read file; do
|   git add --all
|   git commit --all --message="${file} was saved"
| done
`----

The idea behind doing this instead of using emacs to auto-save, was so
that when I used other tools than emacs to edit that directory, the
changes would still be saved.
I don't actually do that currently, but the idea of having it tool
agnostic seemed like a good idea at the time.

> -Ben

HTH,
benny

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

* Re: Keeping org files under git - trimming the repository
  2009-08-04 12:10 Keeping org files under git - trimming the repository Ben Alexander
  2009-08-04 12:26 ` Benjamin Andresen
@ 2009-08-04 13:31 ` Matt Lundin
  2009-08-05  6:18 ` Ian Barton
  2009-08-05  6:53 ` Torsten Wagner
  3 siblings, 0 replies; 5+ messages in thread
From: Matt Lundin @ 2009-08-04 13:31 UTC (permalink / raw)
  To: Ben Alexander; +Cc: org-mode Mailinglist

Ben Alexander <bva@alexanderonline.org> writes:

> About a year ago, I decided to learn how to write "macros" in lisp and
> started by teaching myself about the after-save-hook.  I added a hook
> to auto commit every time I saved any org file.  My simple, small text
> file of todo items is now a giant git repository.
>
> At last a question or two: Does this happen to you? What do you do?
> What new git command do I need to learn in order to do it?

Have you tried running either "git gc" or "git repack" on the repo? I
find that running these two maintenance commands every once and a while
dramatically reduces the size of the repository.

Best,
Matt

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

* Re: Keeping org files under git - trimming the repository
  2009-08-04 12:10 Keeping org files under git - trimming the repository Ben Alexander
  2009-08-04 12:26 ` Benjamin Andresen
  2009-08-04 13:31 ` Matt Lundin
@ 2009-08-05  6:18 ` Ian Barton
  2009-08-05  6:53 ` Torsten Wagner
  3 siblings, 0 replies; 5+ messages in thread
From: Ian Barton @ 2009-08-05  6:18 UTC (permalink / raw)
  Cc: org-mode Mailinglist

> About a year ago, I decided to learn how to write "macros" in lisp and 
> started by teaching myself about the after-save-hook.  I added a hook to 
> auto commit every time I saved any org file.  My simple, small text file 
> of todo items is now a giant git repository.
> 
> At last a question or two: Does this happen to you? What do you do?  
> What new git command do I need to learn in order to do it?
> 
> Is there some way to clone my git repo onto my USB stick, but make it a 
> subset instead of the whole thing?  That would be useful for me to learn 
> for other git projects!
> 
I am not a git expert, but I think there a couple of things you can do:

Create a new branch and push just the branch to your usb stick.

Use git rebase to rewrite all your earlier commits into one huge commit.

Using rebase is a bit like juggling chain saws while walking blindfold 
along a tightrope, so make sure that you pratice on a backup first.

Ian.

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

* Re: Keeping org files under git - trimming the repository
  2009-08-04 12:10 Keeping org files under git - trimming the repository Ben Alexander
                   ` (2 preceding siblings ...)
  2009-08-05  6:18 ` Ian Barton
@ 2009-08-05  6:53 ` Torsten Wagner
  3 siblings, 0 replies; 5+ messages in thread
From: Torsten Wagner @ 2009-08-05  6:53 UTC (permalink / raw)
  To: emacs-orgmode

Hi,
>About a year ago, I decided to learn how to write "macros" in lisp and
>started by teaching myself about the after-save-hook.  I added a hook
>to auto commit every time I saved any org file.  My simple, small text
>file of todo items is now a giant git repository.

please define giant :)
compared to a plain copy of files under git. 
Please consider that every commit create a small overhead to store a commit. 
That means if you commit very small changes every minute or so... your git 
might blow up.
Do you use any autosave function ? 1 one year saving (and commiting) every 15 
min) means 35.000 commits if every auto-commit keeps the sentence "Auto-commit 
from my org-files" :this creates 29 bytes * 35.000 commits which ends up to be 
1 MB just for storing the log-file text. Other values and things will add to 
this.

So please check how many commits you have already.
Repack and gc helps to clean up a bit of the overhead.

As for your concerns to make it smaller again. If you are not interested in 
keeping the history of the files any more, most simply might be just create a 
new git repro, copy the actual versions of the files to this repro and add them 
to git. 

Best regards

Totti

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

end of thread, other threads:[~2009-08-05  6:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-04 12:10 Keeping org files under git - trimming the repository Ben Alexander
2009-08-04 12:26 ` Benjamin Andresen
2009-08-04 13:31 ` Matt Lundin
2009-08-05  6:18 ` Ian Barton
2009-08-05  6:53 ` Torsten Wagner

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).