Question: I've got a git repo that I make automated commits to every day multiple times a day, but now the git repository is getting huge and taking a while to clone onto other devices. I'm wondering what the easiest way would be to slim down my repository. Is there a way to remove older commits to slim down my repository size?

Answer: 
To remove the commits older than one week on master branch, you can use below steps:

1. Get the commits for the last one week which you need to keep by the command

```
git log --oneline --since="one week ago" master

```

Then you will get the commits in last one week as below (latest commit on top, older commit in bottom):

```
d1fc497 (HEAD -> master, origin/master, origin/HEAD) message5
ac89b87 message4
8c3e839 message3
d4ffc42 message2
3f1d63a message1

```

The first/older commit `3f1d63a` need to used in below steps.
2. Checkout an orphan branch from the first commit you want to keep (as the commit `3f1d63a` in above example):

```
git checkout --orphan temp 3f1d63a
git commit -m 'init commit'

```
3. Rebase the last one week commits based on the `temp` branch, and force push `master` branch:

```
git rebase --onto temp 3f1d63a master
git push -f origin master

```

Now `master` branch will only contains the commits for the last one week.

---

To remove the useless objects in your local git repo, you can use below commands:

```
rm -Rf .git/refs/original
rm -Rf .git/logs/
git gc
git prune --expire now

```

Now your local repo's size should be smaller.
git provided `git gc` command and `git repack` to improve the maintaining an old and fat repository. Also there is some un-written rules which could help to prevent the current repository grow fast(i.e using `lfs` for large files and so on).

Use [this](https://confluence.atlassian.com/bitbucket/maintaining-a-git-repository-321848291.html) for more detail.