I have a git repository with multiple branches at the origin. Some of these branches are private (individual) branches that were accidentally pushed to the remote. I do not have the ability to delete the branches on the remote. i.e. - cannot run git branch -d/-D <branch_name>
.
This git repository, now, needs to be migrated to a new repository but without the private and feature branches.
Is my only option to do the following ?
- Create a new empty repository (R1) and clone the repository locally.
- Clone old repository (R1') inside R1.
git checkout <feature_branch>
git branch -d <feature_branch>
git push origin --delete <feature_branch>
.
Or is there a better and smarter way of doing this ? I have about 20 of these feature and private/individual branches that I need to get rid of.