gitflow-avh icon indicating copy to clipboard operation
gitflow-avh copied to clipboard

Git Flow doesn't push after merge causing pull requests to close

Open thedrow opened this issue 10 years ago • 20 comments

Our flow requires us to open a pull request for each branch we merge to develop or master. Git flow doesn't push after merging which causes the pull request to be closed instead of being marked as merged. http://stackoverflow.com/questions/24418711/git-flow-github-pull-request-isnt-working-as-expected is a good explanation of what's going on.

thedrow avatar May 06 '15 08:05 thedrow

there is a way to get around this for now

//use the -k flag to keep the feature branch
git flow feature finish test -k
//after all the merging is done, the PR should be marked as 'merged', so you can delete the remote branch
git flow feature delete test -r

but i agree with you it'd be nice have git flow merge, then delete remote branch automatically

gmedina avatar May 06 '15 16:05 gmedina

Thanks for the workaround.

thedrow avatar May 07 '15 08:05 thedrow

I agree that the default behaviour for this is unexpected, and possibly even dangerous. Pull requests being marked as closed instead of merged is one thing, but I don't want my remote feature branches deleted before the merge has been pushed to develop.

What if there's a conflict when I try to push develop? I've got to make sure I don't accidently lose those commits from the feature branch because my repository may now be the only one that contains them.

buckley avatar Jul 01 '15 03:07 buckley

i just noticed the same thing. I think that the default should be to persist remotes. It's too dangerous the way it is.

esetnik avatar Mar 13 '16 17:03 esetnik

You can set the flags to be default. So if you always want to keep feature, hot fix, bug fix, release branches you can set these flags.

petervanderdoes avatar Mar 16 '16 02:03 petervanderdoes

I'd rather have the branches deleted after Github has marked them as merged.

thedrow avatar Mar 16 '16 09:03 thedrow

Could this be a single option, so that it runs something like the below when finishing a feature? Or do you have a better solution? It would be great to use git flow feature finish, but currently we're doing our merging on GitHub for the aforementioned reasons.

git flow feature finish test -k
git push # Assuming this is needed
git flow feature delete test -r

mrmckeb avatar Aug 21 '16 00:08 mrmckeb

The current behavior also breaks integrations with things like JIRA: to JIRA (and perhaps other similar tools) the PR being closed is a "rejection" from a workflow perspective.

mgk avatar Oct 25 '16 19:10 mgk

@mgk indeed! Nothing new in this case ?

GrzegorzP avatar Jun 02 '17 13:06 GrzegorzP

It looks like #330 will resolve this issue...

I've tested it locally, and as long as 'gitflow.feature.finish.push = true', it all works as I'd expect :D

fatmcgav avatar Dec 01 '17 14:12 fatmcgav

@fatmcgav That PR is not still merged. How to install it?

alex-shamshurin avatar Jul 26 '18 13:07 alex-shamshurin

@alex-shamshurin I just manually applied the patch to my local git-flow file...

fatmcgav avatar Jul 26 '18 13:07 fatmcgav

I wonder to where I should apply the patch... https://github.com/nvie/gitflow and this gitflow-avh what is the difference?

alex-shamshurin avatar Jul 26 '18 13:07 alex-shamshurin

@alex-shamshurin the nvie repo is outdated and probably no longer maintained, avh is the up to date project.

edrpls avatar Aug 29 '18 00:08 edrpls

@edrpls So where is it?

alex-shamshurin avatar Aug 29 '18 08:08 alex-shamshurin

@alex-shamshurin THIS is the gitflow-avh repo. To know what version you have installed, run: git flow version, if it doesn't include the avh suffix then you are on the old nvie version.

edrpls avatar Aug 29 '18 12:08 edrpls

Ok, I have installed this one. BTW, what error line 81: [: -eq: unary operator expected is about? Sounds like a warning.

How to name your supporting branch prefixes?
Feature branches? [feature/]
/usr/local/bin/gitflow-common: line 81: [: -eq: unary operator expected
Bugfix branches? [bugfix/]
/usr/local/bin/gitflow-common: line 81: [: -eq: unary operator expected
Release branches? [release/]
/usr/local/bin/gitflow-common: line 81: [: -eq: unary operator expected
Hotfix branches? [hotfix/]
/usr/local/bin/gitflow-common: line 81: [: -eq: unary operator expected
Support branches? [support/]
/usr/local/bin/gitflow-common: line 81: [: -eq: unary operator expected

alex-shamshurin avatar Aug 29 '18 13:08 alex-shamshurin

I've installed the latest git for windows, git flow version 1.12.0 AVH edition. git flow feature finish still appears to result in "closed" pr's. Is there a config file I need to amend or something?

dazinator avatar May 21 '19 16:05 dazinator

This may help others that get caught out - it's necessary to opt in to this feature, via configuration:

git config --global gitflow.feature.finish.push yes
git config --global gitflow.bugfix.finish.push yes
git config --global gitflow.hotfix.finish.push yes

Failing that, you can opt in via using an additional arg when finishing a feature:

git flow finish -p

As described on comment here

dazinator avatar Jul 03 '19 12:07 dazinator

Failing that, you can opt in via using an additional arg when finishing a feature:

git flow finish -p

The problem seems to be that the target branch, e. g. develop, isn't pushed after merging. This is fixed by git config --global gitflow.feature.finish.push yes.

How would git flow finish -p, "preserve merges while rebasing", help in this case? I've tried it out but it seemed to fail still.

alexanderdavide avatar Jan 25 '23 10:01 alexanderdavide