gpt4 book ai didi

git - 我无法 push git?

转载 作者:IT王子 更新时间:2023-10-29 00:34:31 25 4
gpt4 key购买 nike

git push origin master 显示错误

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.

这是什么?如何恢复?

最佳答案

参见 "pushing a branch" section from GitHub help page :

处理“非快进”错误

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 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.


关于 "Note about fast-forwards" of git push 的模式详情, 如 Michael Mrozek 所述在评论中。

关于git - 我无法 push git?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3598355/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com