1. Bitbucket
  2. Public Issue Tracker
  3. master

Issues

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 (32)

  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. Luis 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 Luis 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. Luis 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. Alexis Barrera reporter

    Oh good, I'm glad you got your bits back =)

    FYI, now's the perfect time to set-up a cronjob on a quiet server to do a git pull every 15 mins ... that way you give yourself a 15 minute failure recovery window should anything odd happen in your repo.

  10. bean5

    For bonus points, you can have your cronjob record changes so you can easily recover from force pushes that you wish never had happened...if you catch them early they aren't so bad.

  11. Michael O'Callaghan

    I also too became a victim of this. I am new to BB but I have to say is there anyway back to recovering the removed branch that was deleted even though it failed due to conflicts? It does mean I have to scramble to local copies which I will be able to do so but just as I was starting to feel confident with the web browser merge tools . . . Atlassian can you jump in regarding this please?

  12. Jozef Spisiak

    I just lost couple of pull requests due to this (luckily had a local backup of my work). Please, this is really blocker or at least remove the functionality to close branch if that is causing the branch to be deleted (not sure if it can happen if it is not checked).

  13. Fraser Hardy

    I've just had the same thing happen. The PR wasnt actually showing conflicts, clicked merge with Delete branch ticked. The merge then failed due to conflicts but my branch deleted. The PR still showed the changes but I was unable to access the original branch, and couldnt get latest changes by git pull either with error

    git -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=sourcetree pull --log origin feature/QSERVER-2608_Integrations-set-up-page 
    fatal: Couldn't find remote ref feature/QSERVER-2608_Integrations-set-up-page
    Completed with errors, see above
    

    I had to contact the original developer who luckily still had it on his local. This needs an urgent fix!!

  14. Log in to comment