我从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

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


当前回答

类似的事情也发生在我身上。我创建了一个名为“Feat/name”的分支。 我试着用:

git push——set-upstream origin Feat/name

我和你犯了同样致命的错误

致命:专长/名字不能解析到分支

为了解决这个问题,我创建了一个新的分支,因为我只有很少的文件受到影响。然后我列出了我的分支来删除错误的分支,它显示没有上限:

壮举/名称

我以前用过大写,但从来没有在第一个字符上用过。看起来git不喜欢它…

其他回答

我的2美分…在我的案例中出现这个问题是因为分支名称中的一个拼写错误(大写字母)。我有两个名字几乎一模一样的分支。

我也有这个问题,我的正常分支开始于pb-3.1-12345/namebranch,但我意外地大写了前2个字母PB-3.1/12345/namebranch。在重命名分支以使用小写字母之后,我可以创建分支。

对于我的例子,我曾经有一个大写字母的分支文件夹(或者不管它叫什么),然后我用差分大小写(小写)创建了一个新文件夹,但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.

不同的套管也有同样的问题。

对开发(或master)进行签出,然后将名称(错误的名称)更改为其他名称,如test。

git checkout development
git branch -m wrong-name test

然后将名称改回正确的名称

git branch -m test right-name

然后签出到右名称分支

git checkout right-name

然后推送到远程分支

git push origin right-name

我遇到了同样的问题,并注意到我在检查分支时混淆了套管。我检查了branchName而不是branchName,当我试图推到远程时,我得到了同样的错误。

解决办法:

git push --set-upstream origin BranchName

通过将上游设置为正确的名称,正确的分支在github上更新,然后我能够签出正确的分支名称

git checkout BranchName 

它应该是最新的,你的最后一推。