76

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!

Community
  • 1
  • 1
Paul Cezanne
  • 8,629
  • 7
  • 59
  • 90

7 Answers7

159

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

CharlesB
  • 86,532
  • 28
  • 194
  • 218
  • 2
    Won't `git checkout develop && git pull origin` create a "Merging origin/develop into develop" commit message? Wouldn't `git checkout develop && git rebase origin` (aka `git pull --rebase origin`) be better in this situation? – PeterB Dec 12 '12 at 12:00
  • 1
    @PeterB: yes indeed, if `develop` and `origin/develop` have diverged, but it's not a common situation – CharlesB Dec 12 '12 at 14:00
  • git pull origin was what fixed it for me. I did a merge to my branch instead of rebase. – Steven Rogers Apr 05 '17 at 17:29
  • What to do if my develop is already up to date but still I've got the diverged state for the feature/new branch when I try to rebase it? previously, I've merged feature/old branch into develop, but old and new branches have no conflicts... – norlin Aug 28 '19 at 12:49
  • @norlin Have you rebased your feature branch on `develop`? – CharlesB Aug 28 '19 at 13:41
  • @CharlesB I've tried to do that when I've got this issue with diverged state. I've ended up with making an empty merge between origin feature branch and local feature. Not sure why git denied to make fast-forward... – norlin Aug 29 '19 at 14:26
  • In Intellij: Go to Settings, search for "executive branch operations on all roots" and uncheck this checkmark. – chill appreciator Nov 11 '21 at 12:07
  • Why Git has to be so darn complicated. Look like it was made by linux guys ;) – Gabriel Oct 20 '22 at 12:38
9

Make sure your develop branch is not behind origin, maybe you need to perform

git checkout develop
git pull
git checkout release/x.x.x

And continue the release process

alper
  • 2,919
  • 9
  • 53
  • 102
Bruno Peres
  • 2,980
  • 1
  • 21
  • 19
5

All i had to do was:

  1. git checkout develop
  2. git pull origin develop
  3. git checkout feature/your_feature_name
  4. git flow finish
David Machara
  • 559
  • 9
  • 13
2

you might also want to ((as long it is not officially supported) patch and) use my

git-flow feature finish -p option

https://github.com/nvie/gitflow/pull/253

childno͡.de
  • 4,679
  • 4
  • 31
  • 57
0

You can fetch from $ORIGIN before finish feature with this command:

git flow feature finish -F <name>

(docs)

Manolo
  • 24,020
  • 20
  • 85
  • 130
0

For whoever googling this error, and using Hub-Flow - just do:

git hf update
Shoham
  • 7,014
  • 8
  • 40
  • 40
-2

For solve that problem you can use my implementation of git flow, based on @childno͡.de solution.

git flow feature/hotfix/release/bugfix  -e finish <name>

To install git flow execute in console:

git clone https://github.com/wyhasany/gitflow-avh/;cd gitflow-avh/;git checkout feature/force_merge;git pull;sudo make install
Michał Rowicki
  • 1,372
  • 1
  • 16
  • 28