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
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
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
> 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.
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