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

Re: Deleting first commits; maintaining last commits

From
Emily Shaffer <nasamuffin@google.com>
Date
Feb 21, 2025, 16:05 UTC
Message-ID
<CAJoAoZmsLu8DukvMugU6z6C=gKFP=dwDhZAT=_jE6h+dO9V55A@mail.gmail.com>
In-Reply-To
<20250221-intrepid-furry-wapiti-eebff0@lemur>

On Fri, Feb 21, 2025 at 7:18 AM Konstantin Ryabitsev <konstantin@linuxfoundation.org> wrote:

Show 27 quoted lines
>
> On Fri, Feb 21, 2025 at 12:18:09AM +0000, brian m. carlson wrote:
> > > My Git repository on GitHub <https://github.com/espindula/br-blfs> has
> > > about 23,500 commits. However, there are several old (before Feb, 28
> > > 2022) commits I would like to delete and maintain the newer ones
> > > (after Feb, 28 2022). So, Is there any Git command (or combined
> > > commands) I could use?
> >
> > No, Git doesn't offer such a thing.  Due to the use of cryptographic
> > hashes used, it would be impossible to verify the integrity of the
> > repository if it could just be truncated like that.  In addition, the
> > goal of Git as a version control system is to track history, not to
> > destroy it.
> >
> > However, if the concern is size and not something else (like removing
> > personal information), then you could use a shallow clone to just
> > download a certain number of revisions and work on that.  The full
> > history would remain on the server, and you could still push newer
> > changes, but the size on your local machine would be smaller.  If you
> > need more history, you could use a partial clone instead if you're
> > willing to be online to work.
>
> Another approach is to create a new repository and use a graft/replacement
> commit to indicate that history continues in a different repository, right? I
> do sometimes wish this was a bit easier/more accessible to perform, because
> that would allow creating "epochs" for very large repos. Unfortunately,
> shallow clones tend to be very heavy on the server-side.

For hosts which support it - which I believe includes GitHub - partial clone is generally easier on the server and a little bit less bug-prone than shallow clone.

>
> -K
>
Previous: Konstantin RyabitsevNext: brian m. carlson
Message 4 of 6 in “Deleting first commits; maintaining last commits”
  1. Jamenson EspindulaFeb 20, 2025
  2. brian m. carlsonFeb 21, 2025
  3. Konstantin RyabitsevFeb 21, 2025
  4. Emily ShafferFeb 21, 2025
  5. brian m. carlsonFeb 21, 2025
  6. Elijah NewrenFeb 21, 2025

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.