Git:合并后“大师无法解析为分支”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11860362/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git: 'Master cannot be resolved to branch' after merge
提问by Chris
Every time I merge a branch back into my master branch, I can no longer push to origin. I get the message fatal: master cannot be resolved to branch
每次我将一个分支合并回我的主分支时,我都无法再推送到原点。我收到消息fatal: master cannot be resolved to branch
I made a simple test change:
我做了一个简单的测试更改:
- Created a new branch
git branch TestBranch
- Made a change to TestBranch and commited
- Checked out back to master
git checkout Master
- Merged TestBranch
git merge TestBranch
- 创建了一个新分支
git branch TestBranch
- 对 TestBranch 进行了更改并提交
- 签出回到主人
git checkout Master
- 合并测试分支
git merge TestBranch
The merge seems to have gone fine, but now when I use Git status the Master branch does not tell me that it is ahead of the origin. And when I try to push to origin Master I get the message above.
合并似乎进行得很顺利,但是现在当我使用 Git status 时,Master 分支没有告诉我它在原点之前。当我尝试推送到 origin Master 时,我收到了上面的消息。
Does anybody know what is causing this problem?
有谁知道是什么导致了这个问题?
回答by Eivind Eidheim Elseth
Could it be that you write Master instead of master? If the system is case sensitive they wouldn't match, and lower-case master is the default in most repositories.
难道你写的是Master而不是master?如果系统区分大小写,它们将不匹配,并且在大多数存储库中小写 master 是默认设置。
回答by rlegendi
Another issue might be this with your workflow:
另一个问题可能与您的工作流程有关:
Created a new branch git branch TestBranch
创建了一个新分支 git branch TestBranch
With the command above, you createa branch, but do not switch to it.
使用上面的命令,您创建了一个分支,但不要切换到它。
I believe you should checkout manually by git checkout TestBranch
orcreate the branch with checkout and create it by git checkout -b TestBranch
.
我相信您应该手动结帐git checkout TestBranch
或使用结帐创建分支并通过git checkout -b TestBranch
.