问题
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?
回答1:
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/
回答2:
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)
来源:https://stackoverflow.com/questions/23723461/how-can-i-share-a-git-configuration