我最近在 Linux Mint Terminal 的 GitHub 帐户中推送了我的第一个存储库。这很简单。我可以看到我所有文件的存储库都在那里。我也能够成功克隆它。搞定。
现在我只想更新我的 README.md 文件或任何其他文件,并使用命令行工具将此单个文件更新到 GitHub 帐户。不知何故,我无法做到这一点。我不想登录我的 github 帐户并在那里编辑文件,因为这样我的本地和存储库就不会相同(除非我再次将它拉回我的本地机器)。
我试过这个:
在第 4 步中,我收到以下错误:
Username for 'https://github.com': xxx
Password for 'https://xxx@github.com':
To https://github.com/xxx/MyTest.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/xxx/MyTest.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?缺少任何东西或整个事情本身都是错误的。我没有得到直接的答案。请建议。
错误消息基本上告诉你你需要做什么,也就是git pull. 您的问题是,自从您拉取后,其他人已将工作提交给master不属于您本地master分支的远程分支。尝试拉动以解决此问题:
git pull origin master
Run Code Online (Sandbox Code Playgroud)
您可能会因此遇到合并冲突,在这种情况下,您必须解决它们,然后手动提交。在此之后,您应该能够毫无问题地推送:
git push origin master
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6067 次 |
| 最近记录: |