git fetch/merge 非快进更改?
我猜我有一个功能分支(所以不是master
),我对其进行了更改(例如修改提交、重新设置基础等),因此它具有等待获取/合并的非快进提交。
我该怎么做?
当我 git fetch 时,git 告诉我,它需要强制更新。所以 nff 提交现在是本地的。我被困在这里了。
我尝试了 git rebase 或 git merge ,但没有任何效果像我想要的那样。
最后我做了像
git merge origin/branchname
然后我有一个合并提交,逻辑上什么也不做。
并且 git reset --hard 会返回到最后一次提交。
一定有更好的方法来做到这一点......但是如何呢?
Guess I've a feature branch (so not master
) which I changed (e.g. amend a commit, rebased or so) so it has non-fast-forward commits waiting for fetch/merge.
How can I do this?
When I git fetch, git tells me, that it needed to force the update. So the nff commits are locally now. And here I'm stuck.
I tried to git rebase
or git merge
but nothing does it like I want it to.
Finally I did it like
git merge origin/branchname
then I had a merge commit which logically does nothing.
And git reset --hard
it back to the for last commit.
There must be a better way to do this... but how?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您的合并
origin/branchname
在逻辑上不执行任何操作,则意味着远程分支没有自己的任何提交,从而向本地分支引入新的更改:尽管你的历史已被改写,但这两个分支是相同的。
因此,最简单的下一步是 git push --force originbranchname,以便用本地历史记录替换
branchname
的远程历史记录。If you have a merge
origin/branchname
which logically does nothing, that means the remote branch didn't have any commits of its own introducing new changes to your local branch:The two branches are the same, even though your history has been rewritten.
So the simplest next step would be a
git push --force origin branchname
in order to replace the remote history ofbranchname
by your local history.