如何共享git配置? [英] How can I share a git configuration?

查看:87
本文介绍了如何共享git配置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用 git flow 启动了一个新的git仓库,进行了一两次提交并推送了.

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

当我将存储库克隆到新目录中并运行 git flow 命令时,出现错误消息:

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.

错误的原因是,新克隆的目录中的 .git/config 文件不包含git flow配置.

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

如何推送/共享配置,以便存储库的任何克隆都具有正确的配置?

推荐答案

您不能直接共享您的配置

.git 文件夹的内容(旨在)特定于单个安装.

You cannot directly share you config

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

与其尝试直接共享您的配置,不如考虑向存储库添加脚本以设置您要共享的任何配置.例如将具有以下内容的名为 bin/setup 的文件添加到存储库中:

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 ""

提交:

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

并在新克隆上运行它:

-> 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/

这篇关于如何共享git配置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆