Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Is deleting/recreating a branch easiest way to remove large files in history?

Steve Novotny March 1, 2023

I know that reset can be used to backup to previous commits, but is deleting and recreating the branch a quicker and easier way to reduce the size of a branch with large files scattered throughout the commit history?

1 answer

1 accepted

1 vote
Answer accepted
Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 1, 2023

Hi @Steve Novotny,

Welcome to Atlassian Community!

Branches are just pointers to different parts of the history and removing a branch will have no effect on the size of the repository, since the history of the large files is still in it. The only way to remove large files from the history is to clear the history out. You can read more about in this KB.

Steve Novotny March 2, 2023

Thank you. That's what I feared.

Steve Novotny March 2, 2023

I'm assuming if I want to back up to before the big files were pushed, I do the following:

 

git branch <keeper>

git reset --soft <commit id before big push> 

git push --force

git merge --ff-only <keeper>

git branch -d <keeper>

Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 2, 2023

Yes, that is correct.

Steve Novotny March 27, 2023

Thanks.  Just to verify: this will only affect the branch I am working on; it won't affect the main branch.  Is that correct?  

Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 27, 2023

As long as you have not merged the push to the main branch then you will be good.

Like Steve Novotny likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events