git checkout master不会切换分支 - 存储库已损坏? [英] git checkout master does not switch branch - repository broken?

查看:323
本文介绍了git checkout master不会切换分支 - 存储库已损坏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

tl; dr git checkout master 不切换到主分支,根本没有错误或任何输出,我没有任何线索为什么。



我有一个由分支 development 和<$ c $组成的git仓库C>主。我做了一个新的版本库,检查出分支 development 为默认值。

  $ git clone< REPO-URL> - 分支开发
$ git分支-a
*开发
origin / HEAD - >原产地/开发
原产地/开发
原产地/主产地
$ git show-ref
656c781c2affc26792f857baf8e232de07101535参考资料/开发单元/开发单元
656c781c2affc26792f857baf8e232de07101535参考资料/遥控器/产地/ HEAD
656c781c2affc26792f857baf8e232de07101535 refs / remotes / origin / development
cfee1a1761642453edf5d001565f23b50243ff09 refs / remotes / origin / master

引用大师指向的是正确的,该提交确实存在,并且是我主分支的最新提交。



到目前为止,一切看起来很正常,但是当我尝试切换到掌握这种情况正在发生:

$ p $ git checkout master
$ git branch
$ development

没有来自结帐的消息,没有错误,没有任何消息,并且分支未被切换。



到目前为止我尝试过的东西:


  • 创建第二个分支 master2 来自同一个提交=>结帐工作正常。

  • 删除并重新创建分支主机本地和原始地点=>再次无结帐
  • git checkout -b master --track origin / master =>可以工作,但我认为应该不需要使用这个命令,因为这是 git checkout master 应该自动执行的操作

  • 提交并推送到master作品,但不会改变签出问题
  • 我尝试了几个git版本(1.9,2.2)和机器(linux,windows),发生问题无处不在。



还有什么想法?我错过了什么?我的存储库是否损坏?我该如何解决这个问题?

解决方案

当源代码树中有一个文件夹主文件夹时,不幸的是,我没有找到一种方法告诉git将该值解释为分支。重命名该文件夹为我解决了问题。


tl;dr: git checkout master does not switch to master branch, gives no error or any output at all and I have no clue why. Any other branch works fine.

I have a git repository that consists of the branches development and master. I do a fresh clone of the repository, checking out branch development as default.

$ git clone <REPO-URL> --branch development
$ git branch -a
* development
origin/HEAD -> origin/development
origin/development
origin/master
$ git show-ref 
656c781c2affc26792f857baf8e232de07101535 refs/heads/development
656c781c2affc26792f857baf8e232de07101535 refs/remotes/origin/HEAD
656c781c2affc26792f857baf8e232de07101535 refs/remotes/origin/development
cfee1a1761642453edf5d001565f23b50243ff09 refs/remotes/origin/master

The ref master is pointing to is correct, that commit does exists and is the latest commit of my master branch.

So far everything looks normal, but when I try to switch to master this is happening:

$ git checkout master
$ git branch 
* development

No message from checkout, no error, nothing, and the branch is not switched.

Things I have tried so far:

  • Creating a second branch master2 from the same commit => checkout works fine.
  • Deleting and re-creating branch master both local and on origin => again no checkout possible
  • git checkout -b master --track origin/master => works, but I think it should not be necessary to use this command as this is what git checkout master should do automatically
  • Committing and pushing to master works, but does not change the checkout problem
  • I tried several git versions (1.9, 2.2) and machines (linux, windows), problem occurs everywhere.

Any further ideas? What am I missing? Is my repository broken? How can I fix this?

解决方案

I have seen something similar when there is a folder master in the source tree. Unfortunately I didn't find a way to tell git to interpret the value as a branch. Renaming the folder fixed the problem for me.

这篇关于git checkout master不会切换分支 - 存储库已损坏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆