未能将某些参考推送到 'https://github.com/<username>/my-history.git'

failed to push some refs to 'https://github.com/<username>/my-history.git'

我无法使用以下命令更新 github.com 存储库中的源代码。

$ git push -u origin master

显示以下错误:

! \[rejected\]        master -\> master (fetch first)
error: failed to push some refs to 'https://github.com/\<username\>/my-history.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 remote add origin https://github.com/username/my-repo.git
$ git push -f origin master