2

My git repository is starting to get a bit too large. On a single SSD, I have a repository and two clones with a lot of binary files that take up an awful lot of space.

Every day, a cron job pushes the master clone to the repository to create a history of changes over a long period of time.

However, anything over a month old isn't really worth keeping anymore. I'd like to be able to remove those old commits to save a lot of space... programatically.

I've seen plenty of examples using rebase and squash, a couple using gc, and some other really funky ones. Most of these require you to manually type in the commit tags you want to remove.

I want to remove all commits older than 30 days from my repository (I suppose I'll have to configure hooks to collapse the history elsewhere too) every month from a bash script.

4

1 回答 1

0

好的,这个怎么样。它获得第一次提交,然后启动变基。只需删除您喜欢的提交即可。

# Get first commit
git log --format=%H | tail -1 | xargs git rebase -i

参考

于 2013-01-09T01:06:50.540 回答