开发者

git fetch/merge non-fast-forward changes?

开发者 https://www.devze.com 2023-03-04 13:15 出处:网络
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.

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 no开发者_运维问答w. 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?


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 of branchname by your local history.

0

精彩评论

暂无评论...
验证码 换一张
取 消