1

I am sitting with an issue on one of my git repositories within bitbucket.

A feature branch that had a pending pull request with multiple merge conflicts was deleted.

  • The developer had write access to that repository.
  • The developer was told to resolve the merge conflicts
  • The developer deleted his local copy of the branch.
  • The developer claims he didn't have sufficient rights to the remote repository to delete branch.

Question 1. I would like to know if it's industry standard practice to wait for the work to be merged in before deleting the branch.

Question 2. I would like to know if there's a way to recover the commits lost when a non merged branch was deleted?

Question 3. Does the developer have sufficient rights to delete the remote branch?

404notfound
  • 55
  • 1
  • 2
  • 9
  • Concerning 2: The commits are not lost, they're still there. The only thing deleted is the branch, i.e. the pointer to the topmost commit. You can still obtain the HEAD commits' id, e.g. via `git reflog`, check out the commit (by id), re-create the branch and have all your commits back. – kowsky Sep 11 '18 at 09:43

1 Answers1

1

Ans 1. Yes, it is a good practice to wait for the branch to be merged in master and then when the whole team is sure that the code is production ready then developers are free to delete there local copy of the branch.

Ans 2. Yes, if non merged branch is deleted from your local repository but is available on your remote repository then you can take a pull of that branch and than that branch will be available on your local. For further help see this - Git undo local branch delete

Ans 3. Yes, if the branch is made by the developer to complete a task and/or to implement the functionality, after the work is finished and your code is production ready, or is already deployed then you are free to delete the branch and prune your local repo.

samar taj Shaikh
  • 1,165
  • 11
  • 18
  • Thanks for the feedback. Regarding your 2nd answer, the remote branch has been deleted so I can't use `git reflog`. The branch is then completely gone with no way of restoring it. – 404notfound Sep 11 '18 at 14:42
  • what you want to say is, the branch is deleted both from remote repository and local repository !? – samar taj Shaikh Sep 12 '18 at 03:43