📅  最后修改于: 2023-12-03 15:15:17.127000             🧑  作者: Mango
When working with Git, it's common to have many branches that are no longer needed. These branches can be deleted to keep your repository clean.
Sometimes, you may encounter a situation where you have pruned a branch that is still showing up in the Git branch list. This can happen if you are working with a remote repository and have deleted the branch on the remote but not on your local repository.
Here is the command to delete a pruned branch:
git branch -d -r <remote_name>/<pruned_branch_name>
-d
option is used to delete the branch.-r
option is used to delete the remote branch.<remote_name>/<pruned_branch_name>
is the name of the pruned branch.For example, if you have a pruned branch named feature-123
on the remote named origin
, your command would be:
git branch -d -r origin/feature-123
This will delete the pruned branch from your local repository as well.
It's important to note that once a branch is deleted, it cannot be recovered. Make sure you have a backup or have merged any necessary changes before deleting a branch.
In summary, the git branch -d -r
command is used to delete a pruned branch from both the remote and local repository. Use it with caution and make sure to have a backup of your work.