While doing some branch maintenance today, I lost a MR and the associated discussion. Not a tragedy but I'd like to get it back if possible. I found an open GitLab enhancement request to undo branch delete but that doesn't quite seem to be what I want. Here's what happened:
Branch A was pushed to our local installation of GitLab, an MR created, and some discussion ensued. We realized that A was a good start but we needed some significant refactoring. We hoped to keep the branch name for the work we'd ultimately merge/ship so we:
Clearly our mental model of GitLab is wrong. It seems that a post-commit hook or something deletes MRs as a branch is deleted. My question now is: can I get the deleted MR and its discussion back?
There is no retention policy on deleted branches. A deleted Git branch can be restored at any time, regardless of when it was deleted.
You can undo a Git merge using the git reset –merge command. This command changes all files that are different between your current repository and a particular commit. There is no “git undo merge” command but the git reset command works well to undo a merge.
Restoring a deleted branchUnder your repository name, click Pull requests. Click Closed to see a list of closed pull requests. In the list of pull requests, click the pull request that's associated with the branch that you want to restore. Near the bottom of the pull request, click Restore branch.
What Happens If I Delete a Git Branch? When you delete a branch in Git, you don't delete the commits themselves. That's right: The commits are still there, and you might be able to recover them.
I apologize for wasting the communities time. I'm a GitLab newbie and was stumbling around. I didn't stumble far enough. Today we discovered that you can get to the original MR if you have the URL. When you get there, it's Closed, as you'd expect, I suppose. If you go back to the project level and navigate to MRs, then pick the Closed tab, it's there. It likely was there all along but in our panic and newbiness, we didn't find it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With