Git Flow 命令错误:“flow”不是 Git 命令。

36

我对Git非常陌生,正在学习命令行版本。我认为我的git flow没有正确安装。我是从一台电脑上运行这个命令的。

当我运行以下命令时:

git flow feature start JamesTest

我遇到了以下错误:

git: 'flow' 不是 git 命令。参见 'git --help'
你是不是想用下面的命令?

看起来 git flow 命令没有被识别为全局命令?我该怎么解决?


flow 不是 Git 的原生命令。它更像是一个 Git 插件或扩展。你使用的是哪个操作系统? - Chris
嗨,Chris - 我正在运行Win 7企业版。 - NetSystemAdmin
不幸的是,在Windows上安装有些麻烦。如果您从http://git-scm.com/安装了Git,则应遵循MSysGit说明。 - Chris
4个回答

48

您的计算机未安装Git Flow。只需运行以下命令:

macOS:

$ brew install git-flow-avh

Linux:

$ apt-get install git-flow

Windows:

$ wget -q -O - --no-check-certificate https://raw.github.com/petervanderdoes/gitflow-avh/develop/contrib/gitflow-installer.sh install stable | bash

成功安装后,在项目中运行git flow init,然后按照说明配置git流程。来源由Daniel Kummer提供的Git-Flow备忘单

1
brew install git-flow-avhbrew install git-flow 之间有什么区别吗? - Blues Clues

22

已安装Git,但未安装Gitflow。Gitflow是一个Git扩展程序,需要单独安装。

按照GitHub上的说明进行安装即可,然后您就可以使用了 ;)


2
如果您想在Windows上安装Git Flow,请按照以下步骤操作(基于此说明):
  1. Clone the git flow repository

    git clone --recursive git://github.com/nvie/gitflow.git
    
  2. Download the getopt archive and extract the getopt.exe file to the location where Git executable is installed (something like C:\Programs\Git\bin)

  3. Execute the following command, where the argument is the Git path installation (again, something like C:\Programs\Git). You don't need to specify the bin directory here.

    contrib\msysgit-install.cmd "C:\Programs\Git"
    

就是这样。使用命令git flow检查是否一切正常。


谢谢,这组指令比Lubos的其他答案中的指令简单多了 :) - Daniel Tonon

1
对于Mac用户,只需确保已安装git-flow。如果没有安装,请分别运行以下命令:
  1. /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  2. brew install git-flow
  3. export PATH=/opt/homebrew/bin:$PATH
  4. git flow init
有时即使安装了git-flow,它也无法正常工作,您需要在使用git flow之前导出brew
export PATH=/opt/homebrew/bin:$PATH

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接