Is it possible to delete a branch but have the option to revive it / un delete it later ?

Ive got a project with lots of old branches for things we have tried but ultimately didn't make it into production.. they are beginning to be to many branches in this repo and id like to delete some of them.. the only issue is that i may at some point in the future want the code back, is there a way i can hide the branches or delete the branches but un hide or revive / un delete them later ?




2 answers

1 accepted

3 votes

No, there is no way to hide or archive branches in a way that they don't show up in Bitbucket of local clones, while still being able to revive them when necessary.

However, what some have done in cases like this, is make a fork of the repo that exists solely as a place to archive branch refs, while deleting branches that are no longer needed in the main repo. You could automate such approach by writing a script that keeps the fork in sync automatically, pulling in new branches from the main repo, but never pruning them when they disappear upstream.

If you delete an unmerged branch, it will still be possible to retrieve it for a little while, but eventually git's garbage collection will clean it up.

You could tag the commit and then delete the branch, but I'm not sure that would accomplish your goal.  I suppose it would prevent the branch from being listed on the branch list screen.  A tagged commit, because it is still reachable, will remain available for checkout even if it's not on a defined branch anymore.

Yeah, relying on unreachable commits and the mercy of the garbage collector (which is entirely controlled by us, not by the user) doesn't seem like the thing Tim is looking for. As for trading branches for tags, I'm, not sure that would improve things. They still "pollute" the refs namespace and continue to gradually slow down operations both on Bitbucket as locally.

Agreed (and I think I more or less made both points in my answer). Forking is a good idea.

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...

29,886 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