If You Want to Delete a Branch
You've Already Deleted the Remote Branch
And want to delete the corresponding local branch and remove the reference information in your local repository.
Here are the specific steps:
-
Switch to the branch you want to delete:
git checkout <branch_name> // Or use, more recommended to use switch for switching branches git switch <branch_name> -
Delete the remote branch:
git push origin --delete <branch_name>This command tells Git that you want to delete the branch named
<branch_name>on the origin server. -
Delete the local branch:
git branch -d <branch_name>This command will delete the local branch. If the branch hasn't been merged, you can use the
-Doption to force delete. -
Update your local repository to remove the deleted branch references from the remote repository:
git fetch --prune originThe
-pruneoption tells Git to remove all remote branch references that no longer exist in the remote repository.
The above are the steps to delete a local remote branch in a git repository.