Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git flow branches have diverged

Tags:

git

git-flow

I'm using the git flow tools and I've gotten myself in a bit of problem. My git branches have diverged. I've read master branch and 'origin/master' have diverged, how to 'undiverge' branches'? and have tried to follow the steps, both attempting to merge and to rebase my local repository.

    $  git flow feature finish showFindLogs     Branches 'develop' and 'origin/develop' have diverged.     And branch 'develop' may be fast-forwarded.     $  git merge origin/develop     Already up-to-date.     $ git rebase origin/develop     Current branch feature/showFindLogs is up to date.     $ git status     # On branch feature/showFindLogs     nothing to commit (working directory clean) 

How can I get out of this? I'm done with the git flow feature and I'd just like to get my changes up to the remote. Thanks!

like image 481
Paul Cezanne Avatar asked Apr 17 '12 18:04

Paul Cezanne


People also ask

What does it mean when your branch has diverged?

A branch in git is a series of interrelated commits. If two branches follow a non-linear path then they diverge each other. The diagram shows two diverged branches master and feature.

How do I merge two branches?

To merge branches locally, use git checkout to switch to the branch you want to merge into. This branch is typically the main branch. Next, use git merge and specify the name of the other branch to bring into this branch. This example merges the jeff/feature1 branch into the main branch.

What is rebase branch?

From a content perspective, rebasing is changing the base of your branch from one commit to another making it appear as if you'd created your branch from a different commit. Internally, Git accomplishes this by creating new commits and applying them to the specified base.


1 Answers

What happens here is that the remote has received updates, and git-flow requires that develop and origin/develop to be at the same commit before merging back the feature. This is to prevent bad conflicts when publishing the branch.

To solve this, you need to:

  1. sync your local develop with origin: checkout develop, and pull from origin to develop (git checkout develop && git pull origin)

  2. rebase your feature on develop with git flow feature rebase showFindLogs. You may have conflicts here if you're unlucky

  3. check that it doesn't break anything

  4. git flow feature finish showFindLogs

like image 53
CharlesB Avatar answered Oct 03 '22 04:10

CharlesB