jgitflow and pull request

1.7k Views Asked by At

I am new to git. I know few basic things about git and I have quite successful in using it.

So I have a master, develop branch. From develop I have branched out to a feature branch and a release branch. For branching out from develop I used the following commands.

jgitflow feature-start from develop
jgitflow:release-start from develop

Now I am done with the feature and I want to merge into develop. I am doing this for the first time. Now I am confused as to how to do it. Ideally I should be using the below command:

jgitflow:feature-finish

The other option I believe is doing a pull request.

Please let me know which is the correct options and what happens if there are conflicts while using jgitflow:feature-finish

3

There are 3 best solutions below

0
On

The details are available at https://bitbucket.org/atlassian/jgit-flow/wiki/goals/feature-finish

Use the necessary flags like keepBranch, squash based on your requirements.

You should also use featureRebase as true. This will rebase the feature branch before merging from the origin which is develop in your case. This will allow you to handle conflicts in a better way.

0
On

The easiest way to avoid conflict when trying to finish a feature is to adhere to the following workflow before executing finish-feature:

  • git fetch: make sure your local repo copy is up-to-date
  • git checkout develop: go to develop
  • git merge origin/develop: make sure your local develop is up-to-date (origin being the remote's name here)
  • git checkout <feature-branch>: go to you feature branch again
  • git merge develop: Merge and solve conflicts, if any (on you feature branch)
  • mvn jgitflow:feature-finish you already solved the conflicts, so this will work

I would not recommend the featureRebase option which was mentioned in another answer since you said you only know a few basic things about Git. Rebase can complicate things if you have pushed your local feature branch and other people are working on it.
Rebase is only safe to use on local branches since it changes the history.

Regarding pull requests, see Gitflow Workflow With Pull Requests on https://www.atlassian.com/git/tutorials/making-a-pull-request/how-it-works

0
On

Pull Request is essential as it would get the changes reviewed. However, if you merge from the PR, you would still be able to run jgitflow:feature-finish, albeit it will result in keeping the remote branch (if pushed before). Ideal way would be to

  • Raise PR for the feature, get it approved.
  • Run the feature-finish command to merge the changes to develop and clean up the local and remote feature branch.

To resolve conflicts, it is always better to pull from develop locally instead of merging through feature-finish as it can get messy.