【发布时间】:2021-10-04 10:57:00
【问题描述】:
在 VSCode 我“初始化存储库”>“Documents\Visual Studio Code\python\collatz_conjecture”> 阶段更改>“init”和提交>git remote add collatz_conjecture https://github.com/Frappyy/collatz_conjecture.git>推送。推送告诉我“没有配置推送目的地。”。好的,我 cd 到 python 脚本和 .git 所在的本地 collatz conjecture 文件夹并执行git push collatz_conjecture,这给了我以下错误:
To https://github.com/Frappyy/collatz_conjecture.git
! [rejected] main -> main (non-fast-forward)
error: failed to push some refs to 'https://github.com/Frappyy/collatz_conjecture.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 config --global init.defaultBranch main,因为在推送之后,脚本总是在主分支而不是它应该在的主(默认)分支中结束。
运行git pull collatz_conjecture main 说“致命:拒绝合并不相关的历史”。我对 Git 和 Github 的工作原理有一些基本的了解,但这一切都超出了我的知识范围。我之前在 VSCode 上遇到过一些非常烦人的 Git 问题,所以我来了。
【问题讨论】:
-
正确!虽然 README 文件不是空的,但我还是应该尝试强制推送它吗?
标签: git github visual-studio-code