1 Evan@Evan-PC MINGW64 /f/gitskills (master) 2 $ git checkout -b feature1 #create a branch 'feature1' and switch to it 3 Switched to a new branch 'feature1'
Evan@Evan-PC MINGW64 /f/gitskills (feature1) $ git branch -d feature1 #delete this branch 'feature1' error: Cannot delete branch 'feature1' checked out at 'F:/gitskills'
Evan@Evan-PC MINGW64 /f/gitskills (feature1) $ git checkout master #switch to branch 'master' Switched to branch 'master'
Evan@Evan-PC MINGW64 /f/gitskills (master) $ git branch -d feature1 Deleted branch feature1 (was b09fe14).
在切换到其他分支上之后,则feature1分支可以被删除。
原文地址:廖雪峰的官方网站