git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Cutting history

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Jul 10, 2010, 20:12 UTC
Message-ID
<AANLkTilcw6gpGI1TO_iRmComID3n0w2biox0ac1uzNyU@mail.gmail.com>
In-Reply-To
<AANLkTikY8RKseD8K4RVrLHnSdW_Su8hVRPRFkzzz1rGv@mail.gmail.com>
On Sat, Jul 10, 2010 at 11:58, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
Show 9 quoted lines
> As for pruning old history, I thought this *should* work for pruning
> history older than 7 days (given that you dump daily):
>
>    git rebase --strategy=base --onto master~8 master~7
>
> But of course that deletes new commits. I need to freshen up on my
> rebase understanding. Maybe someone else on list knows how to do
> that. I thought git rebase --interactive might work, but I can't get
> it to display the root commit. Maybe you need git-filter-branch.

Thiago Macieira on #git provided the answer. You can do that with grafts and git filter-branch. E.g. rewriting the history so that you only have the 7 latest commits:

    git rev-list HEAD | sed '7q;d' > .git/info/grafts &&
    test -s .git/info/grafts &&
    git filter-branch -f HEAD
Previous: Ævar Arnfjörð Bjarmason
Message 7 of 7 in “Cutting history”
  1. Enrico WeigeltJul 10, 2010
  2. Joshua JensenJul 10, 2010
  3. Chris FreyJul 10, 2010
  4. Jakub NarebskiJul 10, 2010
  5. Martin PetterssonJul 10, 2010
  6. Ævar Arnfjörð BjarmasonJul 10, 2010
  7. Ævar Arnfjörð BjarmasonJul 10, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.