简体   繁体   English

IntelliJ + git 推送失败:“未将分支主机设置为自己的上游”

[英]IntelliJ + git failing to push: “Not setting branch master as its own upstream”

I am a very Junior engineer.我是一个非常初级的工程师。 I'm trying to push a new project to GitHub.我正在尝试将一个新项目推送到 GitHub。 I created a GitHub account and a repository named TeamBuilder.我创建了一个 GitHub 帐户和一个名为 TeamBuilder 的存储库。 When I try to push the project to GitHub via Git/IntelliJ, I get the following error:当我尝试通过 Git/IntelliJ 将项目推送到 GitHub 时,出现以下错误:

在此处输入图像描述

So, when I try to do a pull/merge or a pull/branch default, I get this error:因此,当我尝试执行拉/合并或拉/分支默认设置时,我收到此错误:

在此处输入图像描述

I've read through a few SO posts, including this one and this one , but I'm not sure I understand the command lines, even after reading about them in the Git help documentation.我已经阅读了一些 SO 帖子,包括这个这个,但我不确定我是否理解命令行,即使在 Git 帮助文档中阅读了它们之后也是如此。

When I try to set the upstream branch to master, I get this error:当我尝试将上游分支设置为 master 时,出现此错误:

Warning: Not setting branch master as its own upstream.警告:不将分支主机设置为自己的上游。

How can I successfully push this project to my GitHub repo?如何成功将此项目推送到我的 GitHub 存储库? I'd like some help on this before I continue down the rabbit hole and break something.在我继续深入兔子洞并打破某些东西之前,我需要一些帮助。

Update project action in IntelliJ wants the current branch to have a configured tracked remote counterpart and fails if there is no such. IntelliJ 中的更新项目操作希望当前分支具有已配置的跟踪远程对应项,如果没有,则失败。 So to make it work you can set a tracking from the command line with git branch --set-upstream-to origin/master command.因此,要使其正常工作,您可以使用git branch --set-upstream-to origin/master命令从命令行设置跟踪。

Note origin/master , not a simple master - this should be a reference to a remote branch.注意origin/master ,而不是简单的master - 这应该是对远程分支的引用。 Using such reference is only possible when there is a remote defined in git-config.只有在 git-config 中定义了远程时才可能使用此类引用。 IntelliJ can help with setting remotes, check VCS - Git - Remotes... IntelliJ 可以帮助设置遥控器,检查VCS - Git - Remotes...

As a side note, you can use the Share on GitHub action in IntelliJ to push new projects to GitHub - the action will automatically create a new repo and push the code.作为旁注,您可以使用 IntelliJ 中的 Share on GitHub 操作将新项目推送到 GitHub - 该操作将自动创建新的存储库并推送代码。

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

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