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

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

问题描述

我使用 Git 来管理我的两台计算机和我的开发.我正在尝试向 GitHub 提交更改,但出现此错误:

<块引用>

无法将一些引用推送到 .为了防止您丢失历史记录,非快进更新被拒绝.在再次推送之前合并远程更改.

可能是什么原因造成的,我该如何解决?

拉取 repo 返回以下内容:

<块引用>

*branch master->master(非快进)已经是最新的

推送仍然给我上述错误.

解决方案

GitHub 有一个很好的部分叫做".
或者这两个分支是相连的,但与各自的历史不一致:
请参阅永无止境的 GIT 故事 -我在这里做错了什么?"

<块引用>

这意味着你的 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 got this 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天全站免登陆