简体   繁体   English

如何修复Git中的问题:“更新被拒绝,因为推送的分支提示位于其远程对应的后面”

[英]How to fix issue in Git: “Updates were rejected because a pushed branch tip is behind its remote counterpart”

I'm trying to push commits to a remote and getting this error message: 我正在尝试将提交推送到远程并收到此错误消息:

$  git push origin master
To git@git1.eu1.frbit.com:hbrosuru.git
! [rejected]        ab68c0485d -> master (non-fast-forward)
error: failed to push some refs to 'git@git1.eu1.frbit.com:hbrosuru.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and integrate the remote changes
hint: (e.g. 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

I think I've got in a muddle somewhere by pushing multiple local branches to this single remote branch and I'd like to basically clear out what's on the server and push a whole branch from fresh. 我想通过将多个本地分支推送到这个单独的远程分支,我已经陷入困境,我想基本上清除服务器上的内容并推动整个分支的新鲜。 Is this possible, or is there a better way to fix this error? 这是可能的,还是有更好的方法来解决这个错误?

Ps. PS。 this remote branch is hosted on Fortrabbit so I've not got full access to the server to simply delete the branch and create a new one because Fortrabbit's deployment mechanism is based on Git. 这个远程分支托管在Fortrabbit上,所以我没有完全访问服务器来简单地删除分支并创建一个新分支,因为Fortrabbit的部署机制基于Git。

I'd like to basically clear out what's on the server and push a whole branch from fresh. 我想基本清楚服务器上的内容,并从一个新的分支推动整个分支。

This likely means a force push . 这可能意味着推动力量 Note that force pushing is generally not a safe thing to do, and should especially be avoided when pushing to a shared source code repository like GitHub. 请注意,强制推送通常不是一件安全的事情,在推送到像GitHub这样的共享源代码存储库时尤其应该避免。 But in this situation, where you are pushing to update a PaaS server, it is likely okay. 但在这种情况下,您正在推动更新PaaS服务器,这可能没问题。

You might want to visualize your branches graphically using gitk , git log --all --graph --decorate , or some other tool before force pushing, just to make sure that everything looks as you expect. 您可能希望在强制推送之前使用gitkgit log --all --graph --decorate或其他一些工具以图形方式显示您的分支,只是为了确保所有内容都符合您的预期。

To force push your local master branch to your origin remote's master branch, run 要强制将本地master分支推送到origin远程master分支,请运行

git push --force-with-lease origin master:master

The --force-with-lease argument will cause the force push to succeed only if your local branch is up to date with respect to the one you're pushing to. 只有当您的本地分支与您要推送的分支相关时,--force --force-with-lease参数才会导致强制推送成功。 (This prevents accidental overwriting of commits you don't know about.) I strongly advise using the with-lease variant whenever possible instead of the old --force argument, which is less safe. (这可以防止意外覆盖您不知道的提交。)我强烈建议尽可能使用with-lease变体而不是旧的--force参数,这样不太安全。

暂无
暂无

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

相关问题 更新被拒绝,因为你当前分支的尖端落后于它的远程分支 - Updates were rejected because the tip of your current branch is behind its remote counterpart GitLab 更新被拒绝,因为您当前分支的尖端落后于其远程对应分支 - GitLab Updates were rejected because the tip of your current branch is behind its remote counterpart GitHub更新被拒绝,因为当前分支的提示位于其远程对应的后面 - GitHub updates were rejected because the tip of current branch is behind its remote counterpart 推送到 github 时出错 - 更新被拒绝,因为推送的分支提示在其远程后面 - Getting an error pushing to github - Updates were rejected because a pushed branch tip is behind its remote git 推送 - 更新被拒绝,因为当前分支的尖端落后于远程对应 - git push - updates rejected because tip of current branch behind remote counterpart 如何解决git错误:重命名远程分支时“更新被拒绝,因为当前分支的提示落后” - How to resolve git error: “Updates were rejected because the tip of your current branch is behind” when renaming a remote branch git:“更新被拒绝,因为您当前分支的尖端落后..”但是如何查看差异? - git: "Updates were rejected because the tip of your current branch is behind.." but how to see differences? 如何解决 git 错误:“更新被拒绝,因为您当前分支的提示落后了” - How to resolve git error: "Updates were rejected because the tip of your current branch is behind" Git 更新被拒绝,因为您当前分支(主)的尖端在后面但是分支是最新的? - Git Updates were rejected because the tip of your current branch (main) is behind BUT branch is up to date? 更新被拒绝,因为您当前分支的提示落后 - 但为什么? - Updates were rejected because the tip of your current branch is behind - but why?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM