While moving from GitLab to GitHub, after I executed git push --mirror <URL>
, I noticed that git ls-remote --refs
(in the target repository on GitHub) displayed some refs starting with the refs/merge-requests/
prefix.
Since they are irrelevant to GitHub (they are only used by GitLab),
I want to delete them; how can I do it?
In other words, how can I delete refs from a remote matching a search/filter criterion?
You could use this one-liner shell script to do so (you can use this on Windows, too, e.g. using Git Bash):
git ls-remote --refs \
| grep refs/merge-requests/ \
| cut -f 2 \
| xargs -I {} git push --delete origin {}
Summary:
git push --delete origin
on each matching ref to delete them from remote.Notes:
origin
(though it probably is)