30

I cloned a project and ran git checkout -b develop. When I run git flow feature start feature_name it gives me the following error:

Fatal: Not a gitflow-enabled repo yet. Please run 'git flow init' first.

can any one help me?

Deitsch
  • 1,610
  • 14
  • 28
Melek Yilmaz
  • 409
  • 1
  • 5
  • 16

11 Answers11

66

I got it working by doing the steps mentioned by jpfl @ answers.atlassian.com:

Although this is an old post, just wanted to add to this since I've gotten stuck on this same error. Was able to resolve by doing the following:

  1. Open the .git\config file OR Repository -> Repository Settings -> Remotes -> Edit Config File (Sourcetree 2.7.6)
  2. Remove all the [gitflow * entries and save the file
  3. Close and re-open SourceTree
  4. In the main menu, go to Repository > Git Flow > Initialise Repository (should be enabled now)
Anima-t3d
  • 3,431
  • 6
  • 38
  • 56
  • Unfortunately this didn't work for me. After editing the config i received this error: git init -d Using default branch names. Fatal: Local branch 'master' does not exist. Which branch should be used for bringing forth production releases? - productive - stable Branch name for production releases: [master] Completed with errors, see above so i found this https://jira.atlassian.com/browse/SRCTREE-5798?focusedCommentId=1825386&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-1825386 and ended renaming the branchs as the suggested defaults of gitflow. – Takatalvi Mar 06 '19 at 15:18
  • @Takatalvi did you have a master branch to begin with? – Anima-t3d Mar 06 '19 at 15:48
  • Yep. The only "weird" name was the develop branch, called development, in my case. During the initial config of the git flow i used development as develop branch but it didn't work and it's also a bug from sourcetree. – Takatalvi Mar 06 '19 at 16:11
26

You have to init the git flow on your local repo.

GitFlow are local scripts on your machine and each repository has to have teh metadata (in the config) to use it.

simply run :

# launch the git flow wizard
git flow init


# Use git flow with default values
git flow init -d

And you are set to go.

CodeWizard
  • 128,036
  • 21
  • 144
  • 167
16

I had a different situation.

Background

The other answers are fine if you have never git flow initialized the specific repository you are working with, or you did, and want to re-apply that action to clear some buggy state by first clearing the relevant entries out of your .git/config file.

I also use SourceTree, and noticed it was having this problem.

I found what I had done differently recently was cleared out my local master branch that git flow must have ambiguously considered to be a git flow uninitialized repository, even through I had my usual configuration already present.

Solution

I re-checked out my master branch, and git flow works again (to start a new feature, for example)!

Pysis
  • 1,452
  • 2
  • 17
  • 31
  • 2
    +1 I accidentally deleted local master and started getting this issue. After checkout master the problem was solved – A J Qarshi Nov 13 '17 at 21:12
  • Yes, this is a good answer. There is a bug in git flow that if there's no master branch, it will claim that it's "not a gitflow-enabled repo yet". Will report this. – Tom Anderson Dec 03 '21 at 05:29
9

If anybody run git flow init and it doesn't work, an error like this: git: 'flow' is not a git command. See 'git --help'.


Please follow these commands:

wget http://github.com/nvie/gitflow/raw/develop/contrib/gitflow-installer.sh –no-check-certificate

chmod +x gitflow-installer.sh

./gitflow-installer.sh

git flow init

Tai Le
  • 8,530
  • 5
  • 41
  • 34
  • This is helpful, but no in the context of current question, error mentioned in the question is not that git flow is not found. – Zia Ul Rehman Mughal Nov 11 '16 at 10:02
  • @AbbeyJackson Try the solution in [my answer](http://stackoverflow.com/a/41542589/3163075) I tried the others, but the one described in my answer seems to be the most straightforward solution. – Anima-t3d Jan 09 '17 at 07:02
  • @Anima-t3d Thanks for taking the time to reply, this question already has an accepted answer that worked...essentially I didn't know that gitflow was something I had to initialize. – Abbey Jackson Jan 10 '17 at 17:33
  • @AbbeyJackson I think your machine missing `wget`, how to install it: http://stackoverflow.com/a/33902055/2957534 – Tai Le Mar 13 '17 at 08:53
  • Thanks everyone for your follow up replies, the accepted answer from April 25, 2016 is what I needed to do. – Abbey Jackson Mar 14 '17 at 14:49
5

I got it working by doing the steps on SourceTree:

Settings -> Advanced -> Edit Config File -> Remove all the gitflow * entries and save the file

and now you can set Initialise Repository.

ita9178
  • 65
  • 1
  • 6
  • This worked for me too. I don't think this is a sourcetree specific fix. Rather you can just go to .git/config to and remove all gitflow entries to get a fresh start. – Daan Luttik Aug 29 '19 at 09:24
  • I did your steps then I found that I couldn't initialise again because it couldn't find master, the thing is master was on remote so I just checked out master, I pasted my Config File (I saved a copy before doing changes of course) and then everything worked again, just in case someone have their local develop or production branch deleted you have to checkout again – Fernando Bonet Aug 20 '20 at 14:32
2

There is a bug causing this in the version of git for windows I have installed, Git-2.17.1.2-64-bit.

Here is a fix for this outlined in an issue raised at https://github.com/petervanderdoes/gitflow-avh/issues/372

edit file C:\Program Files\Git\usr\bin\gitflow-common and add a ! just before $(git config --get-regexp gitflow.prefix >/dev/null 2>&1) ... ie change to this around line 297

gitflow_is_initialized() {
gitflow_has_master_configured                    && \
gitflow_has_develop_configured                   && \
[ "$(git config --get gitflow.branch.master)" != "$(git config --get gitflow.branch.develop)" ] && \
! $(git config --get-regexp gitflow.prefix >/dev/null 2>&1)}

Hopefully they fix this soon.

Update 2018/07/23

This just returned even with above fix. Looking at the PR to fix this, should actually remove the $() wrapped around the offending line:

git config --get-regexp gitflow.prefix >/dev/null 2>&1
2

You can remove gitflow.prefix in <project_path>/.git/config, and git flow init again

Bsquare ℬℬ
  • 4,423
  • 11
  • 24
  • 44
gaozhidf
  • 2,621
  • 1
  • 22
  • 17
2

If anybody runs git flow init and it doesn't work resulting in an error like this, git flow is simply not installed on your system.

git: 'flow' is not a git command. See 'git --help'.

Have a look at the GitFlow Wiki to find out how to install git flow. The most common way for Mac and Linux is listed below


Mac

brew install git-flow

Linux

apt-get install git-flow
Deitsch
  • 1,610
  • 14
  • 28
0

Run 'git flow init' and it will automatically initialize all the branches to the respective release branches like production release, next release, hotfix branches etc will be set. Here is a snapshot for that : enter image description here

If you want to reinitialize these you can write: 'git flow init -f' this will force reinitialization.

Mark S
  • 3
  • 2
Deeksha Sharma
  • 3,199
  • 1
  • 19
  • 16
0

If you're using SourceTree version 4.0 on MacOS (Sep 2019 is the last release at the time of this post) you may still run into the same error even after running the git flow init command.
This can happen if you rename any branches (for example, devel instead of develop). It seems that something will error out in git flow, and will not recognise the renamed branches (you might also notice errors mentioning the default branches names instead of the renamed ones that you specified during initialization).

The solution in this case is:

  • delete any git flow configuration from the repository config file (check out this post on how to do it: https://stackoverflow.com/questions/36843062#41542589 )
  • exit Sourcetree (through CMD+Q or quit in the menu bar), then start Sourcetree again
  • initialize git flow with the default values. You can do that either from Sourcetree's git flow button, or manually through the terminal with git flow init -d or git flow init and then accepting all the default suggested values
  • from Sourcetree's branches list rename the local branches to what you're happy with
  • open the repository configuration again and rename branches mentioned in git flow configuration to match the renamed branches that you have, and save the config
  • exit Sourcetree (through CMD+Q or quit in the menu bar)

When you'll start Sourcetree again, you should now be able to use git flow normally.

cristian
  • 866
  • 3
  • 8
  • 26
0

fatal: Not a gitflow-enabled repo yet. Please run "git flow init" first.

Please follow below steps to remove this issue:

  1. Open the .git\config file ( /!\ Show hiden items in your windows file explorer)

  2. Remove all the [gitflow * entries and save the file

  3. Close and (re-open SourceTree)

  4. Go in the main menu, go to Repository > Git Flow > Initialise Repository (should be enabled now)

    Or in the CLI type

    git flow init

Hope this helps you !!!