Deleting old commits

Being fairly new to git and SourceTree I am noticing that a repository on a project I'm working on is starting to grow in size, probably from a whole bunch of uneccessary commits. Is there a way to delete older commits from a repository in SourceTree? There doesn't seem to be a way I can find.. or is my thinking on this an error in approach?


1 answer

0 vote
Jeff Thomas Atlassian Team Jan 27, 2014

Hey Ryan,

You could probably use Git Rebase to squash the commits you don't want onto ones that you want. SourceTree has the option to rebase interactively by right-clicking on a parent commit. I'd create a clone of the repository to experiment with first though.

What's your goal here? Are you wanting to remove older commits because there are a lot of individual commits and clean up the history? Or are you trying to reduce the size of the repository?

Hey Jeff, thanks for the prompt response. How would I go about cloning the repo?

I think the goal here would be a combination of the two, reduce the size and clean up the history as well.


Jeff Thomas Atlassian Team Jan 28, 2014

In SourceTree if you create a new respository, you can either clone again from the remote server or from the local directory on your machine into a new path. That will create a new copy of the repository for you to experiment in.

I don't know if rebase will actually reduce the size of the repository. Do you have a lot of large non-text files committed?

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jun 12, 2018 in Bitbucket

Do you use any Atlassian products for your personal projects?

After spinning my wheels trying to get organized enough to write a book for National Novel Writing Month (NaNoWriMo) I took my affinity for Atlassian products from my work life and decided to tr...

31,334 views 26 12
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you