我收到以下错误。我该如何解决?: git add。 git commit -m't' git push origin development
To git@github.com:myrepo.git
! [rejected] development -> development (non-fast-forward)
error: failed to push some refs to 'git@github.com:myrepo.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.
答案 0 :(得分:67)
您的原始存储库位于本地存储库之前。在推送之前,您需要从原始存储库中下拉更改,如下所示。这可以在您的提交和推送之间执行。
git pull origin development
development
指的是您要从中拉出的分支。
如果您想从master
分支拉出,请输入此分支。
git pull origin master
答案 1 :(得分:5)
您可以在控制台中书写:
git pull origin
然后按TAB并编写“主”存储库
答案 2 :(得分:3)
我也收到错误 ! [remote rejected] main -> main (failure) error: failed to push some refs to '<repository>'
。
才发现是这个原因:
答案 3 :(得分:2)
答案 4 :(得分:1)
在Windows中,您需要使用双引号“”。所以命令就是
git commit -m“t”
答案 5 :(得分:1)
在我的情况下git push
试图推动更多只是当前分支,因此,我得到了这个错误,因为其他分支不同步。
要解决此问题,您可以使用:git config --global push.default simple
这将使git只推动当前的分支。
这只适用于更新版本的git。即:赢得了1.7.9.5
的工作答案 6 :(得分:1)
我使用了此命令,它对我来说很好用:
>git push -f origin master
但是请注意,这可能会删除远程存储库中已有的一些文件。由于情况不同,这对我很方便。我将我的本地项目推送到远程仓库中,但该仓库是空的,但是READ.ME
答案 7 :(得分:0)
我遇到了同样的问题,并解决了以下问题 (如果您在本地文件夹中有一个项目,请按照以下步骤操作):
答案 8 :(得分:0)
就我而言。我遇到了错误,因为在github上将存储库创建到现有项目后,我忘记了提交。所以我解决了:
git add .
git commit -m"commentary"
然后我可以输入:
git push -u origin master
答案 9 :(得分:0)
尝试一下:
有时候#1对我有效,有时#2对我有效。我不确定为什么会这样反应
答案 10 :(得分:0)
请确保您正在推送您所在的当前分支。
App University>git branch
* master
test
然后,你必须将你的代码推送到 master 分支
App University>git push origin master
答案 11 :(得分:-1)
$ git fetch --unshallow origin
$ git push you remote name