简体   繁体   English

git checkout尝试签出提交而不是分支

[英]git checkout tries to checkout commit rather than branch

In my repository, I have a branch named 1348 and a commit with a hash code that begins with 1348 . 在我的仓库,我有一个名为分支1348和与开头的哈希码提交1348

When I execute git checkout 1348 , git switches me to the commit. 当我执行git checkout 1348 ,git将我切换到提交。 How can I specify to switch to branch rather than commit? 如何指定切换到分支而不是提交?

git version shows the following: git version显示以下内容:

git version 2.7.5 git版本2.7.5

According to the documentation, git looks for a branch first and only interprets the argument as a SHA prefix if no branch is found. 根据文档,git首先查找分支,如果没有找到分支,则只将参数解释为SHA前缀。 So two possibilities: 有两种可能性:

1) This behavior may have changed between the version you're using and now; 1)您正在使用的版本和现在的版本之间可能已更改此行为; in that case, you could upgrade git versions. 在这种情况下,您可以升级git版本。

2) Is it possible you're mistaken about the branch existing with exactly this name? 2)你是否可能错误地认为存在这个名称的分支?

There is no argument to specifically tell git that you mean the branch. 没有任何论据可以告诉git你的意思是分支。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM