我无法推动git? [英] I am not able to push on git?
问题描述
git push origin master
显示错误
无法推送一些文件到'
git@github.com:xyz / abc.git'
为了防止您丢失历史记录,非快进更新被拒绝
在再次推送之前合并远程更改。有关详细信息,请参阅'git push --help
'中的'关于
快速转发的注意事项'。
这是什么?如何恢复这个?
处理非快进错误
$ b
有时您可能会在推送时遇到此错误:
$ git push origin master
到../remote/
! [被拒绝] master - > master(非快速转发)
错误:未能将某些文件推送到'../remote/'
为了防止您丢失历史记录,非快进更新被拒绝
合并在再次推送之前远程更改。有关详细信息,请参阅'git push --help'的'非快进'
部分。
起初这个错误可能有些压倒性的,不要害怕。
简单地说,git无法在不丢失提交的情况下在远程进行更改,因此它拒绝推送。通常这是由另一个用户推送到同一分支引起的。
您可以通过获取和合并远程分支或使用pull一次执行这两个操作来解决此问题。
在其他情况下,此错误是由于使用像
git commit --amend
或git rebase这样的命令在本地进行的破坏性更改
。
虽然您可以通过向push命令添加- force
来覆盖远程,但您应该只在if你绝对肯定这是你想要做的。强制推送可能会导致已经提取远程分支的其他用户出现问题,这被认为是不好的做法。如果有疑问,请勿强制推送。
a href =http://www.kernel.org/pub/software/scm/git/docs/git-push.html#_note_about_fast_forwards =nofollow noreferrer> 关于快进的提示 git push
,正如迈克尔Mrozek 的评论。
git push origin master
shows an error
failed to push some refs to '
git@github.com:xyz/abc.git'
To prevent you from losing history, non-fast-forward updates were rejected Merge the remote changes before pushing again. See the 'Note about fast-forwards' section of 'git push --help
' for details.
What is this? How to recover this?
See the "pushing a branch" section from GitHub help page:
Dealing with "non-fast-forward" errors
From time to time you may encounter this error while pushing:
$ git push origin master
To ../remote/
! [rejected] master -> master (non-fast forward)
error: failed to push some refs to '../remote/'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes before pushing again. See the 'non-fast forward'
section of 'git push --help' for details.
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
orgit 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.
Mode details on the "Note about fast-forwards" of git push
, as mentioned by Michael Mrozek in the comments.
这篇关于我无法推动git?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!