无法在 SourceTree gitflow 中创建新的修补程序

Unable to create a new hotfix in SourceTree gitflow

你好,这是我的 git 工作流程。我正在尝试使用 Sourcetree 创建一个新的修补程序。不幸的是我得到这个错误:

There is an existing hotfix branch (issue-#001). Finish that one first.

我已经完成了 issue-#001。为什么我无法创建新的?

看起来你已经有了同名的修补程序 检查验证:

git branch 

你应该看到 hotfix/XXXX 你用什么名字

如果要重新创建同名分支,您需要删除现有分支。 Git 不允许您创建名称重复的分支。

您也可以尝试通过合并到最新的 master 来更新 hotfix 分支,然后在更新的分支上工作

如果您需要多个修补程序,可以设置一个配置选项。

git config --add gitflow.multi-hotfix true

这将允许多个修补程序,但默认情况下不允许。您可以为每个存储库或全局添加此选项。

检查现有的修补程序:

git branch | grep hotfix

它为您提供了修补程序分支的全名,在您的例子中为 issue-#001。如果不再需要,请删除分支:

git branch -D issue-#001

要查看 issue-#001 的内容,运行

git stash
git checkout issue-#001
git status
git diff

您需要删除您创建的最后一个 hotfix(仅以 hotfix 命名的分支,不带斜线),然后再创建新分支。当您尝试创建新的 hotfix 时(如果您在 command prompt 上),您将收到以下消息:

Switched to a new branch 'hotfix/XXXXX'

Summary of actions:
- A new branch 'hotfix/XXXXX' was created, based on 'main'
- You are now on branch 'hotfix/XXXXX'

Follow-up actions:
- Start committing your hot fixes
- Bump the version number now!
- When done, run:

     git flow hotfix finish 'XXXXX'

运行 如果需要,以下命令能够使用多个修补程序分支:

git config --add gitflow.multi-hotfix true