刚刚发现,删除后仍然可以切换回分支。 这是我的一个特殊示例:
git switch master
git branch -d AB-10/add_flights
...
// deleting also the remote branch on GitHub
git switch AB-10/add_flights
// I see the branch again
怎么会?
最佳答案
原因很简单:您只在本地删除了它。
手册页报告:
Optionally a new branch could be created with either -c, -C, automatically from a remote branch of same name (see --guess), or detach the working tree from any branch with
--detach, along with switching.
由于远程还存在,GIT可以重新切换到它。
通过 git push --delete origin <branch-name>
删除它然后再次尝试检查它...
关于Git:为什么删除后还能切换到分支?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73275144/