未接受对 github 的新提交。

New commits to github aren't getting accepted.

我编写了一个在线食品订购系统,并将代码上传到 github。检查这个 link.
当我尝试从我的终端进行新提交时,它 returns 出现以下错误。

Username for 'https://github.com': akulkarni9
Password for 'https://akulkarni9@github.com': 
To https://github.com/akulkarni9/miniNet.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/akulkarni9/miniNet.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.  

我对新提交使用了以下命令:
git commit -m "second commit"
git add --all
git push -u origin master
执行这 3 个命令时出现上述错误。我该如何解决?

注意在之前需要加上git commit.

由于您有尚未推送的本地提交,最好执行 git pull --rebase(以便在更新后的 origin/master 分支上重播您的本地提交)

如果 git pull 由于本地更改可能被覆盖而失败,则需要隐藏:

git stash
git pull --rebase
git stash pop

这是一个常见问题,即错误:

git push origin master
To https://github.com/Joey-project/project.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/Joey-project/project.git'

有人告诉我,发生这种情况的最常见原因是因为不应将 his/her 分支推送到更新的远程分支。

我读到其中一种解决方案是使用类似的东西:

git fetch origin; git merge origin/master

我不确定,但是您已经看过这个 link For Ruby on Rails project pull request, git push to my fork failing 了吗? 它可以提供一些额外的信息。

干杯。

All of the commits on that repository 是一个人,大概是你自己。这里的其他答案考虑了其他人将提交推送到您的存储库的可能性,但情况似乎并非如此。

如果您设法自己获得它,那么您可能使用了 git commit --amendgit rebasegit reset 或类似的方法来丢弃本地存储库中的旧提交。在那种情况下,您几乎可以肯定 想要 从您的远程存储库中删除它们,并且命令很简单:只需将 --force 选项添加到 git push.