什么是“Git推送非快进更新被拒绝”意思? [英] What does "Git push non-fast-forward updates were rejected" mean?

查看:828
本文介绍了什么是“Git推送非快进更新被拒绝”意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Git来管理我的两台电脑和我的开发。我尝试对GitHub进行更改,并收到错误消息。


无法将某些参考文献推送到<回购> 。为防止您丢失历史记录,非快进更新被拒绝。再次推送前合并远程更改。


有什么可能导致这种情况,我该如何解决这个问题?



编辑:



拉回购回报如下:


*分支主人 - >主人(非快进)
已经到期日期


推送仍然给我提到上述错误。 GitHub has一个很好的部分叫做。

或者两个分支已连接,但与其各自的历史记录不一致:

请参阅永无止境的GIT故事 - 我在这里做错了什么?
$ b


这意味着你的Subversion分支和你的远程git master分支不会达成一致。

有些更改是推送/提交到一个不在其他的。
启动 gitk --all ,它应该给你一个线索,错误 - 在历史中寻找叉子。



I'm using Git to manage my two computers and my development. I'm trying to commit changes to GitHub and I'm getting the error.

Failed to push some refs to <repo>. To prevent you from losing history, non-fast-forward updates were rejected. Merge remote changes before pushing again.

What could be causing this and how can I fix this?

EDIT:

Pulling the repo returns the following:

*branch master->master (non-fast-forward) Already-up-to-date

Pushing still gives me the aforementioned error.

解决方案

GitHub has a nice section called "Dealing with "non-fast-forward" errors"

This error can be a bit overwhelming at first, do not fear.
Simply put, git cannot make the change on the remote without losing commits, so it refuses the push.
Usually this is caused by another user pushing to the same branch. You can remedy this by fetching and merging the remote branch, or using pull to perform both at once.

In other cases this error is a result of destructive changes made locally by using commands like git commit --amend or git rebase.
While you can override the remote by adding --force to the push command, you should only do so if you are absolutely certain this is what you want to do.
Force-pushes can cause issues for other users that have fetched the remote branch, and is considered bad practice. When in doubt, don’t force-push.


Git cannot make changes on the remote like a fast-forward merge, which a Visual Git Reference illustrates like:

This is not exactly your case, but helps to see what "fast-forward" is (where the HEAD of a branch is simply moved to a new more recent commit).


The "branch master->master (non-fast-forward) Already-up-to-date" is usually for local branches which don't track their remote counter-part.
See for instance this SO question "git pull says up-to-date but git push rejects non-fast forward".
Or the two branches are connected, but in disagreement with their respective history:
See "Never-ending GIT story - what am I doing wrong here?"

This means that your subversion branch and your remote git master branch do not agree on something.
Some change was pushed/committed to one that is not in the other.
Fire up gitk --all, and it should give you a clue as to what went wrong - look for "forks" in the history.

这篇关于什么是“Git推送非快进更新被拒绝”意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆