我设置了几个 git 存储库,每次我设置一个新存储库并进行第一次提交和推送时,此命令都会失败git push origin master
,并且我会收到一些关于它如何无法推送一些 refs 的错误。
----@--------- /c/git/repo/---- (master)
$ git push origin master
--------------------------------
--------------------------------
To -----------------------------
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/-----/----.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again. See the
'Note about fast-forwards' section of 'git push --help' for details.
但是,如果我这样做了git push --force origin master
,为什么会这样,为什么我每次都必须这样做?