我正在研究我的项目,并将其成功推送到GitHub。一切进展顺利,以某种方式我弄乱了项目,删除了本地版本,然后转到GitHub,并使用download
图标下载了整个项目。
在完成项目并进行了少量更改之后,当我尝试将其推向原始位置时,它向我显示了以下错误。
To https://gitlab.rz.uni-bamberg.de/abc/def/bla.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://gitlab.rz.uni-bamberg.de/abc/def/bla.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 init
git add .
git commit -m "changes"
git remote add origin https://gitlab.rz.uni-bamberg.de/abc/def/bla.git
git push -u origin master
[请帮助我,我现在该如何上传。非常感谢
您收到此错误的原因是,现在您有远程没有的本地提交,或者/和远程有本地没有的提交。
如果执行git pull --rebase
,它将为您对本地分支进行排序,那么push将正常工作。