Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
推送被拒绝后git重新基址修复_Git_Github_Rebase - Fatal编程技术网

推送被拒绝后git重新基址修复

推送被拒绝后git重新基址修复,git,github,rebase,Git,Github,Rebase,我已经将一个特性分支推送到github,我意识到我想要重新设置基址,以便压缩一些提交。我跑 git rebase HEAD~5 在我的本地分支上,设置除第一次和最后一次提交之外的所有内容以“修复”。我保存并退出,重新设置的基础继续良好。当我试着推的时候,我会 error: failed to push some refs to 'git@github.com:username/repo.git' hint: Updates were rejected because the tip of

我已经将一个特性分支推送到github,我意识到我想要重新设置基址,以便压缩一些提交。我跑

git rebase HEAD~5
在我的本地分支上,设置除第一次和最后一次提交之外的所有内容以“修复”。我保存并退出,重新设置的基础继续良好。当我试着推的时候,我会

 error: failed to push some refs to 'git@github.com:username/repo.git'
 hint: Updates were rejected because the tip of your current branch is behind
 hint: its remote counterpart. Integrate the remote changes (e.g.
 hint: 'git pull ...') before pushing again.

有没有一种方法可以不用push-f来实现这一点,或者这是我唯一的办法?是否有更好的方法来压缩提交?

唯一的方法是使用
git push-f
。您删除的提交(通过将其替换为一个压缩的提交)已在远程服务器上。如果没有
-f
,则只能添加提交,而不能删除/替换提交

另一方面,如果还没有人拉动,这应该不是问题