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

Re: Purging old history

From
Jakub Narebski <jnareb@gmail.com>
Date
Mar 31, 2012, 08:25 UTC
Message-ID
<m37gy1b2j0.fsf@localhost.localdomain>
In-Reply-To
<CALkWK0=mcQR3CBMpa5P1f+JwqNMqUs3D4=tVPx4c_4R+TXCKbw@mail.gmail.com>
Ramkumar Ramachandra <artagnon@gmail.com> writes:
> John M. Dlugosz wrote:
> > Is there a simple way to delete old commits, say beyond a certain age,
> > before putting it on the server?  The ancient stuff is not relevant and
> > there are a lot of binaries.  Some users may have trouble with an extensive
> > download when syncing the first time.
It seems that you have XY problem.
One solution to extensive initial download is to create a git-bundle
of all commits up to e.g. some tag, and host it using HTTP, FTP
(which are resumable), or even P2P like BitTorrent.
 
Another solution would be to educate users to use shallow clones,
i.e. use "--depth" option to git-clone... and help git developers make
shallow clones better (there are some unncessary limitations in using
shallow clones).
Show 11 quoted lines
> Yes, although your terminology is wrong: it's not about "deleting"
> commits; simply create a fresh root commit and rebase your work on top
> of it.  As an example, let's say you want to squash history from the
> 67afe1 (the old root) to 7ef42b on the master branch:
> 
> $ git checkout -b newroot 7ef42b
> $ git reset 67afe1
> $ git add .
> $ git commit --amend
> $ git checkout master
> $ git rebase --onto newroot 7ef42b

A simpler solution, one that would work also in presence of merges, is to use grafts mechanism (see gitrepository-layout(5)) to cauterize history, check using git-log or gitk that shortened history is correct, make grafts permanent altering history with git-filter-branch, and finally removing grafts.

P.S. Please read first all the warnings about rewriting history, and about all its disadvantages for downstream.

-- 
Jakub Narebski
Previous: Ramkumar RamachandraNext: Phil Hord
Message 3 of 4 in “Purging old history”
  1. John M. DlugoszMar 31, 2012
  2. Ramkumar RamachandraMar 31, 2012
  3. Jakub NarebskiMar 31, 2012
  4. Phil HordMar 31, 2012

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.