【发布时间】:2019-12-10 20:56:15
【问题描述】:
我正在处理我的项目并成功将其推送到 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 clone功能,而不是下载按钮。