我已经熟悉了创建、 merge 和删除分支。我想知道我在哪里,所以我不会将工作提交到错误的分支。我使用 git branch -a
查看我有哪些分支。我认为星号 *
显示了我当前所在的分支。这是什么意思,当我得到:
*(无分支)
掌握
起源/头部
因为当我 $git checkout mybranch
我希望看到
* 我的分支
掌握
起源/头部
最佳答案
git checkout 手册页确实提到了分支名称参数:
<branch>
Branch to checkout;
- if it refers to a branch (i.e., a name that, when prepended with "
refs/heads/
", is a valid ref), then that branch is checked out.- Otherwise, if it refers to a valid commit, your
HEAD
becomes "detached" and you are no longer on any branch.
因此,您必须 checkout 标签名称(有效提交),而不是 checkout 分支名称,使您的 HEAD a detached one .
关于git - 我在哪里? *(没有分支),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2743640/