# Is there a way to control the number of revisions will be saved by git

9 messages from 2008-12-03 to 2008-12-03. Participants: Tzury Bar Yochay, Johannes Sixt, Arafangion, Jakub Narebski, Jean-Luc Herren, Miklos Vajna.
Thread: https://gitlist.dev/t/16575

## Tzury Bar Yochay, 2008-12-03 11:01

Subject: Is there a way to control the number of revisions will be saved by git
Message-ID: <2f5ea7490812030301p29e944fw5f59943dc352cd09@mail.gmail.com>
URL: https://gitlist.dev/e/2f5ea7490812030301p29e944fw5f59943dc352cd09%40mail.gmail.com

```
Hello Happy Gitters,

Say I wish to save only 100 generations back (per branch).
Is it possible to configure git so it will save only N records back.

If git cannot be configured for that, Is there a way to shrink the repository
manually so it will contain the last N generations?


- Tzury

```

## Johannes Sixt, 2008-12-03 11:22

Subject: Re: Is there a way to control the number of revisions will be saved by git
Message-ID: <49366C03.5080506@viscovery.net>
URL: https://gitlist.dev/e/49366C03.5080506%40viscovery.net
In-Reply-To: <2f5ea7490812030301p29e944fw5f59943dc352cd09@mail.gmail.com>

```
Tzury Bar Yochay schrieb:
> Hello Happy Gitters,
> 
> Say I wish to save only 100 generations back (per branch).
> Is it possible to configure git so it will save only N records back.

No.

> If git cannot be configured for that, Is there a way to shrink the repository
> manually so it will contain the last N generations?

Yes:

  $ git rev-parse HEAD~$N >> .git/info/grafts
  $ git filter-branch HEAD

This assumes that your history is strictly linear and you do not have
tags. It also rewrites the $N commits so that they now have different
SHA1s. For this reason, don't share this repository with anyone - it leads
to confusion.

-- Hannes

```

## Arafangion, 2008-12-03 11:37

Subject: Re: Is there a way to control the number of revisions will be saved by git
Message-ID: <1228304226.23167.8.camel@therock.nsw.bigpond.net.au>
URL: https://gitlist.dev/e/1228304226.23167.8.camel%40therock.nsw.bigpond.net.au
In-Reply-To: <2f5ea7490812030301p29e944fw5f59943dc352cd09@mail.gmail.com>

```
On Wed, 2008-12-03 at 13:01 +0200, Tzury Bar Yochay wrote:
<snip>
> Say I wish to save only 100 generations back (per branch).
> Is it possible to configure git so it will save only N records back.

What would be the advantage in doing that?  Git is designed so that you
have all your history available, and saves data in such a way that it
really doesn't take much space.

How would git be able to perform a merge from one branch to another if
it didn't have this history available?

That said, you could probably chop off the history you don't want by
doing tricks with grafting, and rewriting all your history, but this
would likely use more disk space because your branches wouldn't have
anything in common, and also make it very difficult to merge in the
future.

```

## Tzury Bar Yochay, 2008-12-03 12:47

Subject: Re: Is there a way to control the number of revisions will be saved by git
Message-ID: <2f5ea7490812030447s1239cb19n7a266bc2d00e01dc@mail.gmail.com>
URL: https://gitlist.dev/e/2f5ea7490812030447s1239cb19n7a266bc2d00e01dc%40mail.gmail.com
In-Reply-To: <2f5ea7490812030301p29e944fw5f59943dc352cd09@mail.gmail.com>

```
Thanks for your answers.

love git

```

## Jakub Narebski, 2008-12-03 12:58

Subject: Re: Is there a way to control the number of revisions will be saved by git
Message-ID: <m3ljuxifer.fsf@localhost.localdomain>
URL: https://gitlist.dev/e/m3ljuxifer.fsf%40localhost.localdomain
In-Reply-To: <49366C03.5080506@viscovery.net>

```
Johannes Sixt <j.sixt@viscovery.net> writes:
> Tzury Bar Yochay schrieb:

> > Say I wish to save only 100 generations back (per branch).
> > Is it possible to configure git so it will save only N records back.

Why would you want that, by the way?

> No.
> 
> > If git cannot be configured for that, Is there a way to shrink the
> > repository manually so it will contain the last N generations?
> 
> Yes:
> 
>   $ git rev-parse HEAD~$N >> .git/info/grafts
>   $ git filter-branch HEAD
> 
> This assumes that your history is strictly linear and you do not have
> tags. It also rewrites the $N commits so that they now have different
> SHA1s. For this reason, don't share this repository with anyone - it leads
> to confusion.

Or just use shallow clone

  git clone --depth <depth> <repository>

to have new copy (clone) of <repository> to have only <depth> commits
back.  See man git-commit; but it might be not what you want.

-- 
Jakub Narebski
Poland
ShadeHawk on #git

```

## Jean-Luc Herren, 2008-12-03 13:04

Subject: Re: Is there a way to control the number of revisions will be saved by git
Message-ID: <493683C6.8060902@gmx.ch>
URL: https://gitlist.dev/e/493683C6.8060902%40gmx.ch
In-Reply-To: <1228304226.23167.8.camel@therock.nsw.bigpond.net.au>

```
Arafangion wrote:
> On Wed, 2008-12-03 at 13:01 +0200, Tzury Bar Yochay wrote:
> <snip>
>> Say I wish to save only 100 generations back (per branch).
>> Is it possible to configure git so it will save only N records back.
> 
> What would be the advantage in doing that?

That would be a shallow repository, as is already supported by
"git clone --depth 100".  It can be useful for a number of things,
for example developing simple patches on top of HEAD and sending
them somewhere.

What the OP might want is a way to convert a full repository into
a shallow one (can be done by cloning and deleting the original),
and then be able to make it shallower from time to time, to limit
it to 100 revisions; not sure if that is possible.

jlh

```

## Miklos Vajna, 2008-12-03 13:40

Subject: Re: Is there a way to control the number of revisions will be saved by git
Message-ID: <20081203134036.GR19355@genesis.frugalware.org>
URL: https://gitlist.dev/e/20081203134036.GR19355%40genesis.frugalware.org
In-Reply-To: <m3ljuxifer.fsf@localhost.localdomain>

```
On Wed, Dec 03, 2008 at 04:58:40AM -0800, Jakub Narebski <jnareb@gmail.com> wrote:
> Or just use shallow clone
> 
>   git clone --depth <depth> <repository>
> 
> to have new copy (clone) of <repository> to have only <depth> commits
> back.  See man git-commit; but it might be not what you want.

You mean man git-clone?

This trick can be used only once, since you can't clone a shallow clone.

```

## Tzury Bar Yochay, 2008-12-03 18:20

Subject: Re: Is there a way to control the number of revisions will be saved by git
Message-ID: <2f5ea7490812031020l57ec1a04x257c66549f3dac8a@mail.gmail.com>
URL: https://gitlist.dev/e/2f5ea7490812031020l57ec1a04x257c66549f3dac8a%40mail.gmail.com
In-Reply-To: <2f5ea7490812030301p29e944fw5f59943dc352cd09@mail.gmail.com>

```
> Why would you want that, by the way?
I was thinking of building some experimental application on top of git

```

## Tzury Bar Yochay, 2008-12-03 18:23

Subject: Re: Is there a way to control the number of revisions will be saved by git
Message-ID: <2f5ea7490812031023j6f338eb4v3f272b7d9d88fd33@mail.gmail.com>
URL: https://gitlist.dev/e/2f5ea7490812031023j6f338eb4v3f272b7d9d88fd33%40mail.gmail.com
In-Reply-To: <2f5ea7490812031020l57ec1a04x257c66549f3dac8a@mail.gmail.com>

```
On Wed, Dec 3, 2008 at 8:20 PM, Tzury Bar Yochay <tzury.by@gmail.com> wrote:
>> Why would you want that, by the way?
> I was thinking of building some experimental application on top of git
>

Looking at the numbers (of bytes). GIT's efficiency seems to redundant
this option which was a result of my concern about disk space usage.

GIT creators are magicians!

```
