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
Accepted answer

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
Community showcase
Published Nov 06, 2018 in Bitbucket

Upgrade Best Practices

Hello! My name is Mark Askew and I am a Premier Support Engineer for products Bitbucket Server/Data Center, Fisheye & Crucible. Today, I want to bring the discussion that Jennifer, Matt, and ...

1,914 views 7 10
Read article

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