Git推送被拒绝的“非快进” [英] Git push rejected "non-fast-forward"

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

问题描述

对于 git ,我相当新,但目前正在使用它来管理团队环境中的代码。我有一些rebasing的问题,我使用它们来解决它们。

  git checkout --ours filename.txt 
git add filename。 txt
git rebase --continue

现在我希望推送我的更改,下面的命令:

pre code $ git push origin feature / my_feature_branch
code $

给了我以下错误:

 到ssh:// git @ coderepo.com:7999/repo/myproject.git 
! [rejected] feature / my_feature_branch - > feature / my_feature_branch(非快进)
错误:未能将某些文件推送到'ssh://git@coderepo.com:7999 / repo / myproject.git'
提示:更新被拒绝因为当前分支的提示位于
提示后面:它的远程对象。合并远程更改(例如'git pull')
提示:再次按下之前。
提示:有关详细信息,请参阅'git push --help'中的'关于快速转发的注意事项'。

我可以做些什么来摆脱错误?

PS :我尽量避免使用 - force 选项。

解决方案

看起来,有人在你最后一个 git fetch git push 之间推送了新的提交。在这种情况下,您需要重复您的步骤并再次变换 my_feature_branch

  git fetch 
git rebase feature / my_feature_branch
git push origin feature / my_feature_branch

git fetch 之后,我建议使用 gitk --all 来检查情况。


I am fairly new to git yet currently using it to manage our code in a team environment. I had some rebasing issues and I fixed them using

git checkout --ours filename.txt
git add filename.txt
git rebase --continue

Now I wish to push my changes, and so running the following command

$ git push origin feature/my_feature_branch

gives me the following error:

To ssh://git@coderepo.com:7999/repo/myproject.git
 ! [rejected]        feature/my_feature_branch -> feature/my_feature_branch (non-fast-forward)
error: failed to push some refs to 'ssh://git@coderepo.com:7999/repo/myproject.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

What can I do to get rid of the error?

P.S. : I am avoiding to use the --force option as much as possible.

解决方案

It looks, that someone pushed new commits between your last git fetch and git push. In this case you need to repeat your steps and rebase my_feature_branch one more time.

git fetch
git rebase feature/my_feature_branch
git push origin feature/my_feature_branch

After the git fetch I recommend to examine situation with gitk --all.

这篇关于Git推送被拒绝的“非快进”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆