Skip to content

Refs are not cleaned up for deleted merge requests

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Merge requests have refs associated with them, e.g. refs/merge-requests/10/head. These refs are cleaned up after two weeks for merged merge requests. (This cleanup may depend on a configuration setting.)

When a merge request is deleted, I also expect the ref to be removed, either immediately upon deletion or after the cleanup period of two weeks. However, the ref remains.

In a test project, I created two branches with changes and made merge requests for each. I merged MR 9 and deleted MR 10. Then I checked with git ls-remote which refs are available.

Immediately after merging/deleting, it shows that refs for both merge requests still exist:

$ git ls-remote
245034c470e7c687a1247fd00bbcdac435454ea7	HEAD
...
9eb2937265ebf71b05992ac6d1fb273c5a8be019	refs/merge-requests/10/head
148d5b84f8f472b3100aeb0e6778b8b8cff0d7e7	refs/merge-requests/10/merge
92a4040c465a87fe675c5bceac88d1ff0d84033c	refs/merge-requests/9/head
979de050a30f7ec11233da2f981435e01784084f	refs/merge-requests/9/merge

After two weeks, the merged merge request ref has been removed, but the deleted merge request ref still exists:

$ git ls-remote
b13dc0476ee6a6bbf66462e10e5b76173c39a512	HEAD
...
9eb2937265ebf71b05992ac6d1fb273c5a8be019	refs/merge-requests/10/head
148d5b84f8f472b3100aeb0e6778b8b8cff0d7e7	refs/merge-requests/10/merge

I would expect the ref for the deleted merge request to also have been removed by now. Perhaps immediately upon deletion?

Edited by 🤖 GitLab Bot 🤖