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

Re: Deleting first commits; maintaining last commits

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Feb 21, 2025, 00:18 UTC
Message-ID
<Z7fGQalzCg_Fx-ub@tapette.crustytoothpaste.net>
In-Reply-To
<CAOW_YOkX8K=7i7w9c5oH5Cfia0kCzwC3=ok5E=eUwYgpcOKTRQ@mail.gmail.com>
On 2025-02-20 at 22:53:06, Jamenson Espindula wrote:
> Hi all.
Hi,
Show 5 quoted lines
> 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.

I'll note that 23,500 commits is not that many. Git itself has 76,212 commits in my local copy, Linux has over 1,335,000, and I routinely work on a work project with over 500,000. Git should scale much farther than that provided you don't have a really misshapen repository.

-- 
brian m. carlson (they/them or he/him)
Toronto, Ontario, CA
Previous: Jamenson EspindulaNext: Konstantin Ryabitsev
Message 2 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.