Skip to content

Loading…

hotfix: Why do we have to give branch name using finish? #152

Closed
zedtux opened this Issue · 4 comments

3 participants

@zedtux

Hello,

I'm starting to use Gitflow this month and so started to use hotfix and feature option of gitflow.

About feature, as we can create many at the same time, I very understand why we have to give the feature name, but for hotfix, as we can't have more than one at the same time, why do we have to give the branch name?

Here is the scenario:

$ git flow hotfix start test
Switched to a new branch 'hotfix/test'

Summary of actions:
- A new branch 'hotfix/test' was created, based on 'production'
- You are now on branch 'hotfix/test'

...

Then if I try to create another hotfix:

$ git flow hotfix start test2
There is an existing hotfix branch (test). Finish that one first.

Until here, everything is fine. Now I try to stop the unique hotfix that I've created:

$ git flow hotfix finish
Missing argument <version>
usage: git flow hotfix [list] [-v]
   git flow hotfix start [-F] <version> [<base>]
   git flow hotfix finish [-Fsumpk] <version>

Am I right or is there something I forgot ?

@ansell

Not sure if I am correct in my understanding, but I would think you would assign a new release version after you complete a hotfix. The < version > it is requesting in the error message isn't a branch name as the issue title says, but the name of a tag to give the hotfix-ed version when you commit it back into the production branch. There is no point in having two hotfix branches open for a single version, as they are designed to be shortlived . You may want to explore the use of the gitflow support option if you want to support more than one released version and make hotfixes simultaneously to both.

Have you tried passing the < version > or < base > parameters to the git flow hotfix start command btw (as indicated in the help messages that appear on the terminal)? Where < version > is the name of a tag that you have performed a release on on your production branch, or < base > as the commit hash.

@zedtux

Thank you for your answer, but I am not sure too if I am correct in my understanding.

When I give a version like this:

git flow hotfix finish 1.2

Then I got:

Branch 'hotfix/1.2' does not exist and is required.

Because the <version> or <branch_name> is test in my example.

In my understanding, gitflow is really requesting branch name, like for feature for example.
So when I have a bug in a particular feature (like a search for example), then I have understood that I have to do:

git flow hotfix start FixSearch

It create an hotfix/FixSearch branch that will be showed in the git log when it will be merged back to production and develop.

@six8

hotfix is assuming you named your branch as a version, like 1.2 instead of test. Since you named it "FixSearch" you should instead do git flow hotfix finish FixSearch.

I created an alias for git finish which simply finishes whatever branch (feature, hotfix, etc) you have open so I don't have to deal with remembering the branch name or what type of branch it is when I finish it:

# Finish current git flow branch (git finish)
finish = !"git flow $(BRANCH=$(git for-each-ref --format='%(refname:short)' `git symbolic-ref HEAD`); echo ${BRANCH%/*} finish ${BRANCH##*/})"
@zedtux

@six8 Thank you! That's a good starting point, and I will fix my issue with a the kind of hack, but I think that this issue is more a behavior issue.

Maybe the hotfix option has been implemented like all other options (feature, support, ...), so with a parameter to the finish command, where it is not needed.

To fix the destiny of this issue, I think that @nvie should define if my issue report is valid (and has to be implemented like for example change the hotfix finish command in order to set the parameter as optional) or invalid (then I will close it).

@zedtux zedtux closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.