Saving certain amounts of commits in history with git

I have one repository in which there are a lot of large binaries. Is it possible to install git so that it saves only the last n number of commits? For example, do I want to save the last 5 copies of files in this repository history? But I would really like it to not be done manually every 5 commits?

+6
git
source share
4 answers

Use "git rebase --interactive". Mark the first five commits as “select,” and the rest as “squash.”

+3
source share

The only way to do this is to periodically rewrite the repository.

The end contains a hash of commit metadata, commit data, parent (s), and the tree you commit. It is impossible to change something in the past without affecting the present.

+4
source share

As Dustin mentioned, the only way to do this is to periodically rewrite the repository. Git definitely does not have “built-in” support for this and is unlikely to have such support in the near future (a fundamental design of this type excludes this feature). This means that if you want to do this, you will have to do it manually.

If you want to try, the answer to this question shows an example of how this can be done with git filter-branch .

+3
source share

Kindasorta. git clone --depth N will allow you to make a "small clone" in the repository. However, you cannot click / clone / fetch from this, so it is not very useful as a developer.

+2
source share

All Articles