I have one repository where a lot of large binary files live. Is it possibly set git to make it keep only last n number of commits? Such as i only want to keep last 5 copies of files in this repository history? But i would very like to not do this manually every 5 commits?
Kindasorta. git clone --depth N
will let you do a "shallow clone" of the repository. However, you cannot push/clone/fetch from this so it's not very useful as a developer.
The only way to do that is to periodically rewrite the repository.
A commit contains a hash of the commit meta data, the commit info, the commit's parent(s) and the tree you're committing. It's not possible to change something in the past without affecting the present.
As Dustin mentioned, the only way to do that is to periodically rewrite the repository. Git definitely doesn't have "built-in" support for this, nor is likely to have such support any time soon (the fundamental design of the thing kind of precludes this feature). That means if you want to do it, you're going to have to do it manually.
If you want to give it a try, the answer to this question shows an example of how this can be done using git filter-branch
.
Use "git rebase --interactive". Mark the first five commits as "pick" and the remainder as "squash".