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

Re: how to squash a few commits in the past

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
May 3, 2010, 10:09 UTC
Message-ID
<4BDEA0D7.9090201@drmicha.warpmail.net>
In-Reply-To
<loom.20100503T112508-677@post.gmane.org>
Gelonida venit, vidit, dixit 03.05.2010 11:33:
Show 29 quoted lines
> Hi,
> 
> 
> 
> I posted already a similiar question about how to squash the all the commit
> hostory older than a certain commit into one commit.
> 
> 
> This question is slightly different.
> 
> 
> I'm having a git repository.
> 
> Suddenly I noticed, that git pull became rather slow.
> 
> The reason:
> One of the team members accidentally commited a very huge file together with
> some useful sources.
> a few commits later he noticed his error and removed the huge file.
> 
> 
> 
> The plan would be:
> - create a new git repository without the huge file
> - let everybody clone the new repository and continue working.
> 
> 
> I thought, that I could squash the commit adding the file, removing the file and
> the commits in between into one commit.

You don't need to squash the commits in between. Use git rebase -i A^ if A is the commit introducing the large file. Then, either edit that first commit (to not add the file) or reorder so that the removal commit is squashed into A.

If everything looks fine people can pull and rebase. Note that in the source repository, there will still be a large "blob" until you prune and repack.

Michael
Previous: GelonidaNext: Gelonida
Message 2 of 8 in “how to squash a few commits in the past”
  1. GelonidaMay 3, 2010
  2. Michael J GruberMay 3, 2010
  3. GelonidaMay 3, 2010
  4. GelonidaMay 3, 2010
  5. GelonidaMay 3, 2010
  6. Ramkumar RamachandraMay 5, 2010
  7. GelonidaMay 5, 2010
  8. Johannes SixtMay 6, 2010

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.