空Git回购卡在无休止的推/拉错误循环中
我最近创建了一个github repo,它是空的,我陷入了重复错误消息的循环中,这些错误消息似乎与git提供的建议消息没有解决方案 我添加一个文件:空Git回购卡在无休止的推/拉错误循环中,git,github,Git,Github,我最近创建了一个github repo,它是空的,我陷入了重复错误消息的循环中,这些错误消息似乎与git提供的建议消息没有解决方案 我添加一个文件: git add filename git commit -m "commit message" git push origin master 这给了我以下信息: Updates were rejected because the tip of your current branch is behind. its remote counterpar
git add filename
git commit -m "commit message"
git push origin master
这给了我以下信息:
Updates were rejected because the tip of your current branch is behind.
its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
所以我试着:
fatal: refusing to merge unrelated histories
然后我尝试:
git push -f
这给了我:
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin master
但如果我尝试,我会得到:
error: failed to push some refs to 'https://github.com/JonathanBechtel/cdc-
dashboard.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
如果我尝试git stash-u
,我会被告知我没有要隐藏的文件
有人对重复出现的错误消息有什么解释吗?使用以下方法:
git pull origin master --allow-unrelated-histories
那么您的git推送应该会成功:
git push origin master
正如所讨论的,您可能在第一次拉取过程中遇到了不相关的历史记录错误,因为您的本地分支显示为新分支,并且与远程分支的历史记录没有任何共同之处。您的本地主分支位于远程主分支的后面。推送前更新本地
$ git pull origin master # update local master
$ git push origin master # push the changes
值得注意的是,这里的最终问题是您没有在GitHub上创建空存储库。GitHub有两种不同的方法来创建存储库:一种是将其保留为空,另一种是创建一个初始README.md文件并提交该文件。您使用了第二种方法,因此您的Git的初始提交与他们的不同。(与“允许不相关的历史记录”标志合并是处理问题的一种简单方法,或者您可以强制推送以放弃GitHub初始提交。)