简体   繁体   English

未知的git分支已签出

[英]Unknown git branch checked out

I have a branch called ChartFeature but I accidentally typed git checkout CHartFeature and ended up with this in powershell/poshgit: 我有一个名为ChartFeature的分支,但我无意中输入了git checkout CHartFeature并最终在powershell / poshgit中使用了它:

C:\git\Charting [CHartFeature]> git status
On branch CHartFeature
nothing to commit, working tree clean

What happened here? 这里发生了什么? If I look in SourceTree it does not show the branch, but I can (and got myself into trouble) when I committed files to this branch which I never created. 如果我查看SourceTree,它不会显示该分支,但是当我将文件提交到从未创建的该分支时,我可以(并使自己陷入困境)。 (I never typed git checkout -b CHartFeature but I did need to merge it into ChartFeature .) (我从未输入过git checkout -b CHartFeature但确实需要将其合并到ChartFeature 。)

If I list the local branches this erroneous branch does not exist: 如果列出本地分支,则此错误分支不存在:

C:\git\Charting [CHartFeature]> git branch
  ChartFeature
  develop
  master

What is git doing when I type git checkout CHartFeature without having created that branch? 在不创建分支的情况下键入git checkout CHartFeature时git在做什么? What happened to the commits I made there? 我在那里所做的提交怎么了?

What's more, is it safe to type git branch -d CHartFeature ? 而且,键入git branch -d CHartFeature是否安全? What would happen if I did? 如果我这样做会怎样?

Seems this issue due to case sensitiveness in Windows. 由于Windows中区分大小写,因此似乎出现了此问题。

Try to rename ./.git/refs/heads/CHartFeature to ChartFeature manually. 尝试重命名./.git/refs/heads/CHartFeatureChartFeature手动。 Or any CHartFeature presented in .git folder. .git文件夹中显示的任何CHartFeature

Check what branches exist on your repo : 检查您的仓库中存在哪些分支:

git branch
git branch -r  # view remote branches

If CHartFeature exists, but ChartFeature doesn't, try renaming your current branch : 如果CHartFeature存在,但ChartFeature不存在,请尝试重命名当前分支:

git branch -m ChartFeature

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

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