Git:为什么删除后还能切换到分支?

标签 git git-checkout git-switch

刚刚发现,删除后仍然可以切换回分支。 这是我的一个特殊示例:

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/

相关文章:

git - 用于 git 标记验证和 git checkout 的组合命令?

git - 使用 Git 检索文件的旧版本

git - 我所在的文件夹在 git 中有什么意义吗?

git - 引入 git switch 后,git checkout 还能做什么?

git - 启动 GitBash 时未执行 .bashrc

git - 这些 git 提交是如何复制到错误的分支中的?

php - git 中的 Wordpress 数据库

git - 如何获取两个 git 分支之间不同提交的列表?