Remove the first commits from Git Code

Asked

Viewed 35 times

0

Is there any way to reduce the history of git by removing older commits? Assuming a Repo has 5000 commits and removing the first 2500 commits.

  • 1

    There is the option of squash which allows you to turn multiple commits into just one, but [I think] needs special care for merge commits. What is the intention to decrease the amount of commits?

  • I’ll migrate to github but I want to keep the history and there only allows 2gb

  • 1

    In this case, deleting commits usually won’t make much difference. The very Housekeeping routines that git does automatically from time to time will be able to do a large compression. Most indicated here would be to search for which objects in the repository are weighing the most and remove them; and most of these objects that weigh heavily are blobs, not commit objects or Tree objects. Have you ever tried to examine your repository to find out where this space is actually being consumed?

  • 1

    Where I work, the company’s main repository has more than 51k commits. What is the space occupied by the repository? About 150MB. A deal was made a few years ago that removed some 5k commits from the history, but for other reasons it was necessary to keep a backup copy of the previous status of the repository. It is virtually stopped in time, getting only maintenance. It has 33k commits and 122MB. Noticed how even with 60% of the total commits of the new repository it has nearly 80% of the space occupied?

  • 1

    This Atlassian material can help better: https://support.atlassian.com/bitbucket-cloud/docs/reduce-repository-size/

  • 2Gb by repository? Code only or have binary files in that repository?

  • What is the size of the folder . git?

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.