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

Re: purging unwanted history

From
Marcel M. Cary <marcel@oak.homeunix.org>
Date
Nov 18, 2008, 14:28 UTC
Message-ID
<4922D127.1020305@oak.homeunix.org>
In-Reply-To
<93c3eada0811161626h69929cd7va3fa4007a2341bae@mail.gmail.com>
Geoff,

I'm able to prune history with git filter-branch. For example, to throw away history on the current branch before commit 171d7661eda111d3e35f6e8097a1a3a07b30026c, I tried:

git filter-branch --parent-filter '
    if [ $GIT_COMMIT = 171d7661eda111d3e35f6e8097a1a3a07b30026c ]; then
        echo "";
    else
        read line;
        echo $line;
    fi'

I found the diff between that commit and it's rewritten version was empty, and diffs to subsequent commits looked sane. It took an hour on the git repository with about 16k commits. I probably should have excluded all the commits I didn't want to keep to reduce processing time.

However, after deleting all but the rewritten branch and cloning the repository, I didn't notice any decrease in the size of .git/, so I'm not sure why you'd want to do that. Also, all the remaining commitIDs changed so any previous clones would have a tough time merging with yours.

Another possibility whose results might be similar in runtime and repository size would be to run git rebase --interactive and squash all the commits together before the ones you want to keep.

Marcel
Geoff Russell wrote:
Show 20 quoted lines
> I have a repository with 5 years worth of history, I only want to keep
> 1 year, so I want to purge the
> first 4 years. As it happens, the repository only has a single branch
> which should
> simplify the problem.
> 
> Cheers,
> 
> Geoff Russell
> 
> P.S. Apologies, but I've asked this question before but didn't get an
> answer which
> I understood or which worked, so perhaps my description of the problem
> was faulty. This
> is a second attempt.
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
Previous: Geoff Russell
Message 5 of 5 in “purging unwanted history”
  1. Geoff RussellNov 17, 2008
  2. Björn SteinbrinkNov 17, 2008
  3. Björn SteinbrinkNov 17, 2008
  4. Geoff RussellNov 17, 2008
  5. Marcel M. CaryNov 18, 2008

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.