Issue #10242 open

Unintentional Branch deletions from Merge with conflicts (BB-11083)

Alexis Barrera
created an issue

I can consistently reproduce the following bug:

I navigate to a branch in a bitbucket repository and click on merge, selecting the "close branch" option. I get a merge conflict (because of a submodule change) and I click cancel (but leave the close branch checkbox selected).

Instead of merely canceling the merge, Bitbucket deletes my branch, even though the merge failed.

I came close a couple of times to losing work, so this is pretty bad. This branch shouldn't have been deleted, for example: https://bitbucket.org/idg-dev/misc/branch/CORE-589

Comments (21)

  1. Brendon McCarthy

    Same issue, except the merge cancelled on its own due to Merge conflict that could not be resolved automatically. The branch was closed, but the commit remains. After Bitbucket cancelled the merge, deleted the branch, landing on the "compare" page, with an orphaned commit comparison to master, but no changes detected. alexis, how did you end up resolving the issue?

  2. Luís Faceira

    I've also experienced in first-hand this problem and I consider it to be a very serious issue that should be addressed with much urgency.

    If the local copy of a branch is deleted (which is something we periodically do after making sure it's published on bitbucket), then this would make us loose all the work that has been done on that branch, which can mean several hours or days of work down the drain.

    Can't the conflicts be proactively detected and the merge button simply not being enabled, such as what happens on pull requests?

    I'm a paying user of the service with several private repositories and I consider this to be urgent to be fixed.

  3. Alexis Barrera reporter

    @bmccarthy_hp I'm still seeing this problem ... but after bravely testing it a few times I think the problem is mostly a UI/Experience issue.

    Basically, this only happens to us on a branch that has already been merged. It seems like the error is more along the lines of can't/don't need to remerge. We should be getting an info message or something, not an error.

  4. Brendon McCarthy

    In the most simple form, the branch should not be deleted (closed) if a merge conflict causes the merge to fail. Technically if the branch is not actually being deleted (?) and is a UI issue, we need to be able to see and manage the branch (both from Bitbucket) and from a Git client.

    We were able to recover using the local branch that still existed and re-commit/push to a new branch (but like Luís Faceira said is not always an option). As it works now, we cannot use Bitbucket UI to merge as we cannot predict what it will do if there is a merge conflict.

  5. Luís Faceira

    I disagree with Alexis Barrera that this is mostly a UI issue. From our experience this does NOT only happen on branches that have already been merged, if that was true, I would agree that this is not such a serious issue.

    But it happens with ALL branches that cannot be merged, either because they've already been merged but also because they have conflicts to be resolved. Since it deletes the origin branch, unless we are lucky to still have the original branch locally, there's no branch for us to solve the conflicts, because such branch was deleted!

  6. Yeen Fei Lim

    please advise what can be done when facing this issue ?!? our feature branch got deleted after an unsuccessful merge, and the origin branch got killed !?! cant believe such important flaw still exist after 6months+...

  7. Davide Balistreri

    Hi all, today I lost two months of committed work on a deleted branch after a failed fast-forward merge issued from the Bitbucket UI. After spending some hours I couldn't recover anything even by using Git through the terminal, but "fortunately" Bitbucket shows some last commits of the lost branch in the recent activity RSS in the Overview of my project. I will try to checkout the last-lost-commit with his identifier, and copy all changed code since the last commit on my master branch. This is unbelievable...

  8. Davide Balistreri

    Hi Alexis, I managed to get access to the original .git folder and then reset the HEAD pointer to the last commit before the failed merge. Then I forced a push towards Bitbucket repository and all the lost work became available again. Thank you for your support!

  9. Log in to comment