[Git] Delete local branch; error error: Cannot delete branch 'wangyunuo-test' checked out at 'XXX'

Table of contents

0. Environment

1. Problem description

2. Solution steps

1) Use the command to switch to other branches

2) View all current local branches

3) Delete the "wangyunuo-test" branch


0. Environment

Windows 11 64-bit + Git + VScode to run the code

1. Problem description

In the process of working on the project, I want to delete a local branch "wangyunuo-test", using the following command to delete (currently I am on this branch)

 git branch -d wangyunuo-test

But after deleting it will report an error:

Reason for problem analysis:

Use the command branch -d to delete a local branch. The premise is that you need to switch to other branches. I deleted this branch on this branch, so an error will be reported. After switching to other branches (any branch), run the command again.

2. Solution steps

1) Use the command to switch to other branches

git checkout + 其他分支名

2) View all current local branches

git branch

3) Delete the "wangyunuo-test" branch

git branch -d wangyunuo-test

successfully deleted

Use [git branch] to view the following current local branches again, and you can see that the "wangyunuo-test" branch is no longer there

--END--

Guess you like

Origin blog.csdn.net/qq_41539778/article/details/132717203