threads / discuss / 16074

exporting the last N days of a repository

Subject: exporting the last N days of a repository

## tl;dr

8 messages between Oct 29, 2008 and Nov 5, 2008.

replies: 7people: 3as markdown or json

Geoff Russell· Oct 29, 2008, 01:01 UTC · lore

I want to export "the last N days" of a repository to create a copy which has an origin which is the state of the repository N days ago and has all the history between then and now.

Can fast-export do this?

Cheers, Geoff Russell

Johannes Schindelin· Oct 29, 2008, 15:10 UTC · re: Geoff Russell · lore

Re: exporting the last N days of a repository

Hi,
On Wed, 29 Oct 2008, Geoff Russell wrote:
Show 5 quoted lines
> I want to export "the last N days" of a repository to create a copy 
> which has an origin which is the state of the repository N days ago and 
> has all the history between then and now.
> 
> Can fast-export do this?
Yes.  See the --since=... option.

Hth, Dscho

Geoff Russell· Nov 3, 2008, 01:16 UTC · re: Johannes Schindelin · lore

Re: exporting the last N days of a repository

On Thu, Oct 30, 2008 at 1:40 AM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:

Show 11 quoted lines
> Hi,
>
> On Wed, 29 Oct 2008, Geoff Russell wrote:
>
>> I want to export "the last N days" of a repository to create a copy
>> which has an origin which is the state of the repository N days ago and
>> has all the history between then and now.
>>
>> Can fast-export do this?
>
> Yes.  See the --since=... option.

Sorry, I didn't explain what I want very well. N days ago I had a working directory in a state S with files F1,F2,F3,... I want to dump all the history before then so that this is my new starting point, so I want to keep all changes since then. In general, this is impossible if there are multiple branches which influence what happens between N and now, but in the simple non-branching case it should be possible.

Fast-export with From..To revisions (or with --since=...) just gives changes since the point N days ago.

Basically I'm trying to do an "rcs -o:1.xyz" where xyz is a version and I want to prune before that to shrink a large and unwanted history.

Thanks, Geoff Russell

Show 5 quoted lines
>
> Hth,
> Dscho
>
>
-- 
6 Fifth Ave,
St Morris, S.A. 5068
Australia
Ph: 041 8805 184 / 08 8332 5069
Johannes Schindelin· Nov 3, 2008, 06:51 UTC · re: Geoff Russell · lore

Re: exporting the last N days of a repository

Hi,
On Mon, 3 Nov 2008, Geoff Russell wrote:
Show 17 quoted lines
> On Thu, Oct 30, 2008 at 1:40 AM, Johannes Schindelin
> <Johannes.Schindelin@gmx.de> wrote:
> >
> > On Wed, 29 Oct 2008, Geoff Russell wrote:
> >
> >> I want to export "the last N days" of a repository to create a copy 
> >> which has an origin which is the state of the repository N days ago 
> >> and has all the history between then and now.
> >>
> >> Can fast-export do this?
> >
> > Yes.  See the --since=... option.
> 
> Sorry, I didn't explain what I want very well.  N days ago I had a 
> working directory in a state S with files F1,F2,F3,...  I want to dump 
> all the history before then so that this is my new starting point, so I 
> want to keep all changes since then.

Well, if you are interested in the history of your _local_ ref, then you should use reflogs:

	$ git log --since=HEAD@{10.days.ago}

Hth, Dscho

P.S.: man git-reflog
Geoff Russell· Nov 4, 2008, 22:49 UTC · lore

Re: exporting the last N days of a repository

Apologies to Johannes and Bob who have tried to help but I'm still having difficulties, here is my current non-working script:

------------------------------------------------------------------
#!/bin/sh
DIR=/tmp/gitdemo
# for testing just arbitrarily
# select the 15th most recent commit as our new origin
NEWORIGIN=$(git rev-list master@{15} | head -1)
echo $NEWORIGIN
# checkout earlist point we are interested in
# we want to drop any history before this point
git checkout $NEWORIGIN
# now make a new directory, initialise with new origin
# and apply all commits after that point
mkdir $DIR && (cd $DIR ; git init) &&  \
    rsync -aHv --exclude=.git ./ $DIR && \
    (cd $DIR ; git add . ; git commit -m "starting point" </dev/null ) && \
    git fast-export $NEWORIGIN..master | (cd $DIR ; git fast-import )
----------------- end of script

The fast-import gives me a message I don't understand and doesn't do the import.

Bob Hiestand· Nov 5, 2008, 00:18 UTC · re: Geoff Russell · lore

Re: exporting the last N days of a repository

On Tue, Nov 4, 2008 at 4:49 PM, Geoff Russell <geoffrey.russell@gmail.com> wrote:

Show 24 quoted lines
> Apologies to Johannes and Bob who have tried to help
> but I'm still having difficulties, here is my current non-working script:
>
> ------------------------------------------------------------------
> #!/bin/sh
> DIR=/tmp/gitdemo
> # for testing just arbitrarily
> # select the 15th most recent commit as our new origin
> NEWORIGIN=$(git rev-list master@{15} | head -1)
> echo $NEWORIGIN
> # checkout earlist point we are interested in
> # we want to drop any history before this point
> git checkout $NEWORIGIN
> # now make a new directory, initialise with new origin
> # and apply all commits after that point
> mkdir $DIR && (cd $DIR ; git init) &&  \
>    rsync -aHv --exclude=.git ./ $DIR && \
>    (cd $DIR ; git add . ; git commit -m "starting point" </dev/null ) && \
>    git fast-export $NEWORIGIN..master | (cd $DIR ; git fast-import )
>
> ----------------- end of script
>
> The fast-import gives me a message I don't understand and doesn't
> do the import.

If I understood your requirement (I know nothing about fast-export), it would look like this:

#!/bin/sh
DIR=/tmp/gitdemo
ORIGDIR=$PWD
git checkout -b shorthistory
NEWORIGIN=$(git rev-list --since='5 months ago' --reverse HEAD| head -1)
echo $NEWORIGIN
git filter-branch --parent-filter '
        test $GIT_COMMIT = '$NEWORIGIN' &&
        echo || cat' \
        --tag-name-filter cat $NEWORIGIN^..
mkdir $DIR
cd $DIR
git init
git fetch $ORIGDIR shorthistory:master
Thank you,
bob
Geoff Russell· Nov 5, 2008, 03:54 UTC · re: Bob Hiestand · lore

Re: exporting the last N days of a repository

On Wed, Nov 5, 2008 at 10:48 AM, Bob Hiestand <bob.hiestand@gmail.com> wrote:
Show 44 quoted lines
> On Tue, Nov 4, 2008 at 4:49 PM, Geoff Russell
> <geoffrey.russell@gmail.com> wrote:
>> Apologies to Johannes and Bob who have tried to help
>> but I'm still having difficulties, here is my current non-working script:
>>
>> ------------------------------------------------------------------
>> #!/bin/sh
>> DIR=/tmp/gitdemo
>> # for testing just arbitrarily
>> # select the 15th most recent commit as our new origin
>> NEWORIGIN=$(git rev-list master@{15} | head -1)
>> echo $NEWORIGIN
>> # checkout earlist point we are interested in
>> # we want to drop any history before this point
>> git checkout $NEWORIGIN
>> # now make a new directory, initialise with new origin
>> # and apply all commits after that point
>> mkdir $DIR && (cd $DIR ; git init) &&  \
>>    rsync -aHv --exclude=.git ./ $DIR && \
>>    (cd $DIR ; git add . ; git commit -m "starting point" </dev/null ) && \
>>    git fast-export $NEWORIGIN..master | (cd $DIR ; git fast-import )
>>
>> ----------------- end of script
>>
>> The fast-import gives me a message I don't understand and doesn't
>> do the import.
>
> If I understood your requirement (I know nothing about fast-export),
> it would look like this:
>
> #!/bin/sh
> DIR=/tmp/gitdemo
> ORIGDIR=$PWD
> git checkout -b shorthistory
> NEWORIGIN=$(git rev-list --since='5 months ago' --reverse HEAD| head -1)
> echo $NEWORIGIN
> git filter-branch --parent-filter '
>        test $GIT_COMMIT = '$NEWORIGIN' &&
>        echo || cat' \
>        --tag-name-filter cat $NEWORIGIN^..
> mkdir $DIR
> cd $DIR
> git init
> git fetch $ORIGDIR shorthistory:master

Thanks Bob but when I ran your version (using master@{15} instead of --since =...) it effectively dropped the recent history, not the old history. Imagine a sequence of 30 commits, no branches. I want to keep, for example, 15 through 30 and dump 1 to 15. So I need to have the working directory as at commit 15 and then all the changes to bring it up to 30.

       ... 11--12--13--14--15 ... 28--29--30
       ... Dump 1 to 15           keep 15 to 30.
Your script kept 1 to 15 and dumped the rest.

Cheers, Geoff.

Show 6 quoted lines
>
>
> Thank you,
>
> bob
>
-- 
6 Fifth Ave,
St Morris, S.A. 5068
Australia
Ph: 041 8805 184 / 08 8332 5069
Bob Hiestand· Nov 5, 2008, 19:49 UTC · re: Geoff Russell · lore

Re: exporting the last N days of a repository

On Tue, Nov 4, 2008 at 9:54 PM, Geoff Russell <geoffrey.russell@gmail.com> wrote:

Show 14 quoted lines
> Thanks Bob but when I ran your version (using master@{15} instead of
> --since =...) it
> effectively dropped the recent history, not the old history. Imagine a sequence
> of 30 commits, no branches.  I want to keep, for example, 15 through
> 30 and dump 1
> to 15.  So I need to have the working directory as at commit 15 and
> then all the changes
> to bring it up to 30.
>
>       ... 11--12--13--14--15 ... 28--29--30
>
>       ... Dump 1 to 15           keep 15 to 30.
>
> Your script kept 1 to 15 and dumped the rest.

I guess that's because you're using reflog syntax and pulling up a commit that isn't on the current branch, due to rebasing, resetting, or any such activity. Using the reflog syntax, for the few commits I tried, produced the desired result.

I'm not sure why you'd use reflogs, however, as I believe the --max-age or --since parameters to rev-list seem to be more in line with your request. Actually, I'd be surprised if you couldn't identify the one commit that you wanted to use and use it directly; the rev-list was just to show an example.

Thank you,
bob

← back to recent threads