Local Git branch has diverged from origin following an interactive rebase

烈酒焚心 提交于 2019-12-07 14:37:51

问题


I have a local branch (CRM-ayrshireminis) that has a couple of commits on it that I have pushed to the origin (origin/CRM-ayrshireminis). This branch was created from the develop branch about one week ago, on which there have been one weeks worth of work from other collaborators.

What I want to do is rebase the latest code from origin/develop into my feature branch CRM-ayrshireminis.

What I done was:

git checkout develop
git pull
git rebase -i develop CRM-ayrshireminis

I had two commits, so I squashed them into one and then quit out. I got the message saying Rebasing (2/2), so it seemed fine...

[crmpicco@dev53 ayrshireminis]$ git status
# On branch CRM-ayrshireminis
# Your branch and 'origin/CRM-ayrshireminis' have diverged,
# and have 2 and 2 different commits each, respectively.
#   (use "git pull" to merge the remote branch into yours)

Is there any way for me to rebase the commits from develop into my branch and squash my two commits into one as I am attempting to do?


回答1:


Is there any way for me to rebase the commits from develop into my branch

You're doing this backwards. You're moving the branch develop on top of your branch, which necessarily causes it to diverge from origin/develop. If your intent is to include new commits from develop in your branch, what you actually want is to rebase your branch on top of develop:

git fetch
git checkout CRM-ayrshireminis
git rebase -i origin/develop
git push -f origin CRM-ayrshireminis


来源:https://stackoverflow.com/questions/22412444/local-git-branch-has-diverged-from-origin-following-an-interactive-rebase

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!