2

I just noticed that if we have local and origin/develop looking like

local:          A---B
origin/develop: A---B

If I then do git flow feature start Z and work for a while I might end up with:

local:          A---B
origin/develop: A---B---C---D

I now do git flow feature finish Z and I get a warning about:

Branches 'develop' and 'origin/develop' have diverged.
And local branch 'develop' is ahead of 'origin/develop'

I now have (no push):

local:          A---B---Z
origin/develop: A---B---C---D---E

I try to do git pull and down comes a bunch of updates that git merges into develop, so I end up with:

local:          A---B---Z-----------Z'
                     \--C---D---E--/
origin/develop: A---B---C---D---E

If I do a git push origin/develop I'm going to muck up our nice neat single develop stream, so after some googling I ended up doing:

git pull --rebase --prune
git push origin develop

This restored me to:

local:          A---B---C---D---E---Z
origin/develop: A---B---C---D---E---Z

Doing this I actually discovered that a previous feature had also failed because of the same problem... I thought we used git flow to hide all these common niggles and pitfalls.

So, am I using git flow wrongly? Is there some extra command one should always do before feature finish to ensure you don't get out of sync?

Ken Y-N
  • 14,644
  • 21
  • 71
  • 114

2 Answers2

2

As I mentioned here, you could set locally:

git config --global pull.rebase true
git config --global  rebase.autoStash true

That way, any pull on develop, done after your git flow finish, would effectively rebase Z (which is not yet pushed) automatically.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
1

I haven't used git flow (but we use git flow approach) and basic git commands are enough.

This may not answer your question directly, but I suggest dropping git flow extension. You won't have to learn two products: git and git flow.

tymtam
  • 31,798
  • 8
  • 86
  • 126
  • Indeed; I had hoped that `git flow` would try a bit harder to do the right thing, but if it cannot get such a simple case right whilst also misplacing another commit. I previously posted about [another quirk regarding unstaged commits](https://stackoverflow.com/q/51494100/1270789) so I suspect my time would have been more profitably spent studying more `git` features. – Ken Y-N Jul 26 '18 at 03:41