Reputation: 561
I would like to adopt the git-flow tool inside my team.
The problem is that "git flow feature finish" merges the branches locally. And I want to create a pull request instead. Thus, the merge will happen in the origin.
So, what is the right way to use the git-flow tool in teams that also work with pull requests?
Tried to google it but could not find something meaningful.
Upvotes: 56
Views: 26261
Reputation: 1565
Old thread but I thought I give it my 2 cents anyway.
In our team we have the following workflow with Git Flow in SourceTree:
Upvotes: 0
Reputation: 705
git flow feature start my-feature
git flow feature publish my-feature
git checkout develop && git pull
git flow feature finish my-feature
. It will be deletes 'my-feature' branch both from local and remote.Upvotes: 2
Reputation: 6416
There is a great solution to this problem, but it does require a custom script since PR APIs are unique to each platform.
The AVH version of git-flow has some additional features: https://github.com/petervanderdoes/gitflow-avh
It has support for hooks (custom scripts): https://github.com/petervanderdoes/gitflow-avh/wiki/Reference:-Hooks-and-Filters#hooks
You can swap to the AVH version on a Mac using:
brew uninstall git-flow
brew install git-flow-avh
To support a pull request in git flow you can add a script:
.git/hooks/post-flow-feature-publish.sh
Example post-flow-feature-publish.sh
script to output a url:
#!/bin/sh
branch=$(git rev-parse --abbrev-ref HEAD)
userRepo=$(git remote -v | grep fetch | awk '{print $2}' | grep "github.com" | cut -d':' -f2 | rev | cut -c5- | rev)
if [ -n "$userRepo" ]
then
echo ""
echo "Create PR at: https://github.com/$userRepo/compare/$branch?expand=1"
echo ""
fi
Or if using the GitHub CLI you could call: gh pr create
https://cli.github.com/manual/gh_pr_create
Now when running the command:
git flow feature my-feature publish
Git flow will push code to the feature branch and call the hook script to create the PR.
Upvotes: 5
Reputation: 1082
You can just use the git flow feature publish <name>
this will publish your feature branch to your origin (like Bitbucket). Then you can create the pull request there and merge it into develop. After that is done, you need to manually delete the local feature branch.
The only command you can not use is git flow feature finish <name>
. This works fairly well and you can still use most of the git flow helpers.
The same goes for releases. I found this article helpfull: https://blog.axosoft.com/pull-requests-gitflow/
Hope this helps a little. There is just not the one perfect solution to this problem.
Upvotes: 56