简体   繁体   English

Git推后拉拒绝

[英]Git push rejected after pull

I've performed the following steps in git: 我在git中执行了以下步骤:

git stash
git pull origin develop
git stash apply
git commit -a -m 'da de da'
git push origin develop
<correct local date>
GIT_COMMITTER_DATE="`date`" git commit --amend --date "`date`"
git pull origin develop
git push origin develop

All the pushes gave this error: 所有的推动都给出了这个错误:

 ! [rejected]        develop -> develop (non-fast-forward)
error: failed to push some refs to '<details>:/var/git/mygagenet'
To prevent you from losing history, non-fast-forward updates were rejected

How do I correct this problem? 我该如何解决这个问题?

This part of the error message: 错误消息的这一部分:

To prevent you from losing history, non-fast-forward updates were rejected 为了防止您丢失历史记录,拒绝了非快速更新

tells you why the push was rejected - it doesn't just add new commits on top of the existing ones (which Git calls a "fast-forward update"), but it changes commits you've already pushed. 告诉您为什么拒绝推送-它不只是在现有提交之上添加新的提交(Git称之为“快速更新”),而且还会更改您已经推送的提交。 In this case, the git commit --amend on your most recent commit has changed that commit. 在这种情况下,最近一次提交的git commit --amend更改了该提交。

You can force the push to happen by using 您可以使用以下方法强制执行推送

git push --force origin develop

But if this is a remote branch that other people are using, check with them before you use git push --force on the branch, as they may have already done work on this branch with the existing commits. 但是,如果这是其他人正在使用的远程分支,请在使用git push --force之前先与他们核对,因为他们可能已经使用现有提交在该分支上完成了工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM