git push prune to delete remote branches, follow these steps:
- First, ensure that you have the latest changes from the remote repository by running git fetch.
- Run git branch -r to view the list of remote branches. Identify the branches you want to delete.
- Use the git push command with the --prune or -p option, followed by the name of the remote repository, and the branches you want to delete.
For example, to delete a remote branch named "feature-branch", use the following command:
git push --prune origin feature-branch
If you want to delete multiple branches, you can specify them separated by a space:
git push --prune origin branch1 branch2 branch3
- Git will verify the branches to be deleted and ask for confirmation. Review the list and type "y" to confirm the deletion.
remote: Pruning old remote branches...
Note: Be cautious while using
git push --prune as the deleted branches cannot be easily recovered. It is recommended to double-check the branch names before confirming the deletion.