Source branch gets deleted when the PR is merged but "close source branch" is not selected
Platform Notice: Cloud - This article applies to Atlassian products on the cloud platform.
Summary
Branch is getting deleted when PR is getting merged without enabling "close source branch"
Diagnosis
This happens when there is a remnant of the remote branch on the local. For example, if the source branch is called "develop", origin/develop remains on the remote even after the source branch gets deleted. It can also happen when the branch name is origin/develop/feature i.e. When there is a deleted branch but the remote is not completely deleted. You might also see errors like "The upstream is gone".
Solution
This issue can be resolved with the following command -
git remote prune origin
This will remove the errors and remove any unreferenced remote branches.