9

I've initiated a new git repository using git flow, done a commit or two and pushed.

When I clone the repository in a new directory and run a git flow command I get the error:

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

The reason for the error is that the .git/config file in the newly cloned directory doesn't contain the git flow configuration.

How can I push/share the configuration so any clone of the repository will have the correct configuration?

SimonW
  • 6,175
  • 4
  • 33
  • 39

2 Answers2

11

You cannot directly share you config

The contents of the .git folder are (intended to be) specific to an individual install.

Alternative

Instead of trying to directly share your config, consider adding a script to the repository to setup whatever config you want to share. e.g. add a file named bin/setup to the repository with these contents:

#!/usr/bin/env bash

# simple
git flow init -d

# override stuff or whatever
git config gitflow.prefix.versiontag ""
git config gitflow.prefix.feature ""

Commit it:

-> chmod +x bin/setup
-> git add bin/setup
-> git commit -m "adding a setup script to ensure consistent config"

And run it on new clones:

-> git clone ....
-> cd project
-> bin/setup
-> git config -l --local
...
gitflow.branch.master=master
gitflow.branch.develop=development
gitflow.prefix.versiontag=
gitflow.prefix.feature=
gitflow.prefix.release=release/
gitflow.prefix.hotfix=hotfix/
gitflow.prefix.support=support/
Community
  • 1
  • 1
AD7six
  • 63,116
  • 12
  • 91
  • 123
  • 2
    +1. That is the hack I was mentioning in my comment below (http://stackoverflow.com/questions/23723461/how-can-i-share-a-git-configuration/23726067#comment36463591_23723526) – VonC May 18 '14 at 19:38
  • 1
    It's rather hard to answer a git question without (intentionally or not) stating something you've already written somewhere =). – AD7six May 18 '14 at 19:44
  • paying it forward mate, thanks for a great solution. – Spence Oct 01 '14 at 04:23
  • Cool hack, but I have encountered a problem `git flow init -d` will fail if the develop and/or master branches are not present. I solved the problem by first pre-configuring git flow and then run `git flow init -d`. – r4w8173 Sep 07 '18 at 11:16
0

This tutorial does mention

Now that you’ve cloned the Repository, you should run the git flow init command on your local Repository as well to get your local Git configuration to match that of your remote as follows:

git flow init

This should automatically switch you into the develop branch and you should now do a Git pull from your remote to ensure that you have the latest develop branch locally by running the following command:

git pull origin develop

Now that you have your local Repository matching that of your remote on both master and develop you should continue to start a feature branch. git flow feature

So that reflects the error message you have: git clone isn't enough, you need to re-create the git flow config with the git flow init command.
(Since a local git config is never shared)

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I do understand that, as I wrote that the error is because the configuration isn't shared. My question is if there is any way I can share some or all git configuration? – SimonW May 18 '14 at 15:25
  • @SimonW `git flow init` should re-create that git flow config for you then. – VonC May 18 '14 at 15:25
  • @SimonW as I mentioned, you don't share a git config, by design (git flow or no git flow). – VonC May 18 '14 at 15:26
  • I'll try to explain myself better, I understand that I can't share the `.git/config`, is there any other way/method/hack to share some/any git configuration? (and sorry if I'm bugging) – SimonW May 18 '14 at 15:30
  • 1
    @SimonW you are not bugging, and this is a very valid question, but a/ not really (unless you version the config file, and then symlink the `.git/config` to it once cloned, but that is really not a good practice), b/ I wonder what config you would need to share and which isn't appropriately re-created by the `git flow init` command after a `git clone` of a git flow-managed repo? – VonC May 18 '14 at 15:32
  • thank you for your help! My current need can easily be re-created with the `git flow init` but as many programmers work on this repository I wish to make it as foolproof as I can. – SimonW May 18 '14 at 19:42
  • 1
    @SimonW if they are all using the same workflow manager (`git flow`), then they will have to follow an initialization step like `git flow init` (or a custom wrapper like AD7six's answer, but I wouldn't recommend it, as it is one more wrapper around a wrapper) – VonC May 18 '14 at 19:44