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

Re: How to remove a commit object?

From
KLKlas Lindberg <klas.lindberg@gmail.com>
Date
Oct 2, 2008, 14:52 UTC
Message-ID
<33f4f4d70810020752g4738fee3p4e99ab417d97106a@mail.gmail.com>
In-Reply-To
<48E4DB21.7020304@drmicha.warpmail.net>

What I really want is to remove files, but when filter-branch didn't seem to do what I wanted, I turned to the idea of rewriting single commits to not include the files in question.

This is what I tried with filter-branch: gitk --all shows about 170 commits on directory D in the repo. Of these, maybe 10 don't lead to HEAD, but dangle off the main track. As a test, I decided to let filter-branch create a new repo that only contained the contents of subdirectory B. So I ran

    git-filter-branch --subdirectory-filter B -- --all

and now the resulting repo has just 14 commits. This is clearly not what I wanted because a lot of the original history for subdirectory B is just missing.

Actually, in this particular case I get the exact same result with
    git-filter-branch --subdirectory-filter B HEAD
BR / Klas

On Thu, Oct 2, 2008 at 4:30 PM, Michael J Gruber <git@drmicha.warpmail.net> wrote:

Show 23 quoted lines
> Klas Lindberg venit, vidit, dixit 02.10.2008 16:26:
>> Repo size is a problem too, actually.
>>
>> A solution to both problems seemed to be to use git-filter-branch to
>> create a new repo by filtering out all the unwanted files. The
>> astonishing result was that, for the subdirectory I tried it on, 90%
>> or so of the commits on that subdirectory just disappeared. It didn't
>> look right at all. Although I can't say for sure exactly what I did
>> with filter-branch, I would appreciate some guidance for using it. It
>
> I don't know about others, but I would appreciate more info:
> Do you want to remove commits (as stated earlier) or files (as stated here)?
> What are the boundary conditions? Rewriting history seems to be OK now.
>
>> basically seemed to do exactly what I wanted (recreate the repo, minus
>> some explicit stuff, with history intact otherwise), except the result
>> looked crazy.
>
> That may be due to the filter-branch incarnation, i.e. which refs did
> you rewrite (--all or HEAD)?
>
> Michael
>
Previous: Michael J GruberNext: Johannes Sixt
Message 8 of 11 in “How to remove a commit object?”
  1. Steven GrimmSep 18, 2008
  2. Michael J GruberSep 19, 2008
  3. Klas LindbergOct 2, 2008
  4. Michael J GruberOct 2, 2008
  5. Jakub NarebskiOct 2, 2008
  6. Klas LindbergOct 2, 2008
  7. Michael J GruberOct 2, 2008
  8. Klas LindbergOct 2, 2008
  9. Johannes SixtOct 2, 2008
  10. Klas LindbergOct 3, 2008
  11. Johannes SixtOct 3, 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.