我从Bitbucket或Github迁移了我的回购。我认为这无关紧要,但这是唯一不同的地方。有一段时间,我设置了两个遥控器:

origin: bitbucket
github: github

然后我删除了这两个,并指向github的起源:

git remote remove origin
git remote remove github
git remote add origin https://github....

开发部门测试推送:

git push origin develop

一切都是最新的,很好。

像往常一样为一些工作创建一个新分支:

git checkout -b Feature/Name

更新一两个文件。尝试推送到远程:

git push origin Feature/Name

这导致了错误:

致命:特征/名称不能解析到分支

在网上搜索这个问题,找到一些关于确保HEAD是正确的,其他关于确保我的分支名称大小写是正确的(尽管,此时远程上还不存在分支)。无法解决。

执行如下命令:

git push --all -u

这让我的功能/名称分支到github,但仍然看到相同的行为之前:

git push origin develop
git push origin Feature/Name

第一个可以工作,而第二个抛出相同的错误。为什么?


当前回答

如果你在本地分支,可以重命名分支“Feature/Name”为“Feature/Name”

git -m功能

如果你在推git时遇到问题,在其他分支(ex develop)进行签出,然后返回到重命名的分支

git签出特性/名称

再试试你的git push

其他回答

@Ty Le的回答略有修改:

我不需要修改文件——我有一个名为“Feature/…”的分支。,在往上游推的时候,我把标题改成了“feature/…”(第一个字母的大小写被改成了小写字母)。

对于我的例子,我曾经有一个大写字母的分支文件夹(或者不管它叫什么),然后我用差分大小写(小写)创建了一个新文件夹,但git实际上用大写创建了分支。

I have created a branch like feature-ABC/branch1 before and pushed it. Then I create a branch feature-abc/branch2 (notice the lower-case ABC), and try to push it to remote using git push --set-upstream origin feature-abc/branch2 and get the 'cannot be resolved to branch' error. So I git branch and see that it actually created feature-ABC/branch2 instead of feature-abc/branch1 for me. I checkout again with git checkout feature-ABC/feature2 and push it using the uppercase (feature-ABC/feature2) to solve it.

如果你使用的是Omegaman/BugFix这样的文件夹,请确保案例是正确的。似乎你可以签出一个现有的分支作为小写omegaman/BugFix并尝试推送,它会失败。

用正确的外壳重新检出,如git检出Omegaman/BugFix来解决。

我遇到了同样的问题,这是由于去分支错误的套管。git让我切换到分支与不正确的套管即功能/名称而不是功能/名称。找到了一个比上面列出的更简单的解决方案:

提交你的更改到'feature/Name' Git主签(或开发) Git签出特性/名称<使用正确的大小写 git推

分公司名称请用小写字母,不要用大写字母。它会起作用的。