在使用VSCode和devcontainers时,我遇到了同样的问题。正在使用的版本是:
root@abc64e31b32e:/workspace
1.12.0 (AVH Edition)
注意:此方法实际上不起作用。在空存储库上进行的第一个初始化导致.git/config
文件不包含[gitflow "prefix"]
部分。当执行git flow feature start ABC
时,默认使用全局部分来创建feature/ABC
分支。进行随后的git flow init --default -f
会导致看到相同的错误。
Ubuntu 20.04软件包中存在一个已报告的错误:https://bugs.launchpad.net/ubuntu/+source/git-flow/+bug/1860086
通过从GitHub获取1.12.3版本并替换安装的gitflow/git-flow文件,可以解决此问题。
wget https://github.com/petervanderdoes/gitflow-avh/archive/1.12.3.tar.gz
tar xzf 1.12.3.tar.gz
cd gitflow-avh-1.12.3/
cp git* /usr/lib/git-core/
另一种方法是在全局级别设置前缀:
git config --global gitflow.prefix.feature 'feature/';
git config --global gitflow.prefix.bugfix 'bugfix/';
git config --global gitflow.prefix.release 'release/';
git config --global gitflow.prefix.hotfix 'hotfix/';
git config --global gitflow.prefix.support 'support/';
git config --global gitflow.prefix.versiontag '';
git config --global gitflow.branch.master master;
一个带有前后示例的端到端实现:
注意: 全局主分支配置实际上无效。即使在1.12.3版本也是如此。
root@abc64e31b32e:/workspace# mkdir wrong
root@abc64e31b32e:/workspace# cd wrong
root@abc64e31b32e:/workspace/wrong# git init
Initialized empty Git repository in /workspace/wrong/.git/
root@abc64e31b32e:/workspace/wrong# git flow init --defaults
Using default branch names.
No branches exist yet. Base branches must be created now.
Branch name for production releases: [master]
Branch name for "next release" development: [develop]
How to name your supporting branch prefixes?
Feature branches? []
Bugfix branches? []
Release branches? []
Hotfix branches? []
Support branches? []
Version tag prefix? []
Hooks and filters directory? [/workspace/wrong/.git/hooks]
root@abc64e31b32e:/workspace/wrong# cd ..
root@abc64e31b32e:/workspace# git config --global gitflow.prefix.feature 'feature/';
root@abc64e31b32e:/workspace# git config --global gitflow.prefix.bugfix 'bugfix/';
root@abc64e31b32e:/workspace# git config --global gitflow.prefix.release 'release/';
root@abc64e31b32e:/workspace# git config --global gitflow.prefix.hotfix 'hotfix/';
root@abc64e31b32e:/workspace# git config --global gitflow.prefix.support 'support/';
root@abc64e31b32e:/workspace# git config --global gitflow.prefix.versiontag '';
root@abc64e31b32e:/workspace# git config --global gitflow.branch.master master;
root@abc64e31b32e:/workspace# mkdir working
root@abc64e31b32e:/workspace# cd working
root@abc64e31b32e:/workspace/working# git init
Initialized empty Git repository in /workspace/working/.git/
root@abc64e31b32e:/workspace/working# git flow init --defaults
Using default branch names.
No branches exist yet. Base branches must be created now.
Branch name for production releases: [master]
Branch name for "next release" development: [develop]
Hooks and filters directory? [/workspace/working/.git/hooks]
root@abc64e31b32e:/workspace/working# git flow feature start ABC
Switched to a new branch 'feature/ABC'
Summary of actions:
- A new branch 'feature/ABC' was created, based on 'develop'
- You are now on branch 'feature/ABC'
Now, start committing on your feature. When done, use:
git flow feature finish ABC
root@abc64e31b32e:/workspace/working#
git flow init -f -d --feature feature/ --bugfix bugfix/ --release release/ --hotfix hotfix/ --support support/ -t ''
- creativeDev