Gitflow: git flow init 在克隆的 repo 上失败。

创建于 2011-04-26  ·  29评论  ·  资料来源: nvie/gitflow

我可能做错了,但是如果我尝试克隆一个只有develop分支的存储库,然后尝试使用git flow feature start foo启动一个功能,那么它会告诉我重新初始化 git flow . 运行git flow init失败,因为master分支不存在。 我必须手动创建它才能工作。

这对我来说似乎是错误的。 在幕后,当然,git flow 应该创建所需的分支,或者只是处理它们不在那里。 这听起来像一个错误吗?

这是一个示例会话:

oj<strong i="12">@mint</strong> ~/tmp $ git init test
Initialized empty Git repository in /home/oj/tmp/test/.git/
oj<strong i="13">@mint</strong> ~/tmp $ cd test
oj<strong i="14">@mint</strong> ~/tmp/test $ git flow init
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? [feature/] 
Release branches? [release/] 
Hotfix branches? [hotfix/] 
Support branches? [support/] 
Version tag prefix? [] 
oj<strong i="15">@mint</strong> ~/tmp/test $ echo "foo" > test.txt
oj<strong i="16">@mint</strong> ~/tmp/test develop * $ git add test.txt
oj<strong i="17">@mint</strong> ~/tmp/test develop * $ git commit -m "testing"
[develop 9ebdd64] testing
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 test.txt
oj<strong i="18">@mint</strong> ~/tmp/test develop $ cd ..
oj<strong i="19">@mint</strong> ~/tmp $ git clone ./test test2
Cloning into test2...
done.
oj<strong i="20">@mint</strong> ~/tmp $ cd test2
oj<strong i="21">@mint</strong> ~/tmp/test2 develop $ git flow feature start foo
fatal: Not a gitflow-enabled repo yet. Please run "git flow init" first.
oj<strong i="22">@mint</strong> ~/tmp/test2 develop $ git flow init

Which branch should be used for bringing forth production releases?
   - develop
Branch name for production releases: [] master
Local branch 'master' does not exist.
oj<strong i="23">@mint</strong> ~/tmp/test2 develop $ git branch master
oj<strong i="24">@mint</strong> ~/tmp/test2 develop $ git flow init

Which branch should be used for bringing forth production releases?
   - develop
   - master
Branch name for production releases: [master] 

Which branch should be used for integration of the "next release"?
   - develop
Branch name for "next release" development: [develop] 

How to name your supporting branch prefixes?
Feature branches? [feature/] 
Release branches? [release/] 
Hotfix branches? [hotfix/] 
Support branches? [support/] 
Version tag prefix? [] 
oj<strong i="25">@mint</strong> ~/tmp/test2 develop $ git flow feature start foo
Switched to a new branch 'feature/foo'

Summary of actions:
- A new branch 'feature/foo' was created, based on 'develop'
- You are now on branch 'feature/foo'

Now, start committing on your feature. When done, use:

     git flow feature finish foo

oj<strong i="26">@mint</strong> ~/tmp/test2 feature/foo $ 

谢谢!
奥杰

最有用的评论

@kasterma谢谢!

$ git flow init

Which branch should be used for bringing forth production releases?
   - develop
Branch name for production releases: [] 
Local branch '' does not exist.

$ git branch -a
* develop
  remotes/origin/HEAD -> origin/develop
  remotes/origin/develop
  remotes/origin/master

要获取本地分支:

$ git checkout master
$ git checkout develop
$ git branch -a
* develop
  master
  remotes/origin/HEAD -> origin/develop
  remotes/origin/develop
  remotes/origin/master

现在正常运行 git flow init 。

$ git flow init

所有29条评论

我遇到了完全相同的问题。 我还没有在本地创建一个 master 分支(因为这对我来说也是错误的),但我还没有找到不同的解决方案。 但是,如果我能找到一些东西,我会再次发布。

到目前为止,我发现的唯一解决方案是创建 master 分支,即使它没有被使用。 这并不愉快,但它有效。 希望尽快修复它!

跟踪初始主分支不是最明智的,例如
git checkout -t origin/master

当然……如果有的话! 创建新项目时,我不推送
空的master分支,push之后develop里面就没有master了
github也可以。

所以它仍然是一个问题。

从我的 Windows Phone 发送(是的,你没看错)来自:shuane
发送时间:2011 年 7 月 2 日星期六 6:33
至: [email protected]
主题:回复:[gitflow] git flow init 在克隆的 repo 上失败。 (#121)
跟踪初始主分支不是最明智的,例如
git checkout -t origin/master

直接回复此邮件或在 GitHub 上查看:
https://github.com/nvie/gitflow/issues/121#issuecomment -1486906

+1 同样的问题...

+1 相同的问题

在首次创建存储库时不想推送空的初始主分支(默认创建)背后的哲学原因是什么?

如果你不推送 master 分支(因为这里的评论者似乎故意没有做),那么你不能把它拉到一个克隆中。 Git-flow 在不尝试创建新分支方面是正确的,以防您忘记检查预先存在的 master 分支,如果它创建了一个新分支,则会发生冲突。

这没有什么哲学意义。 这与工作流程有关。 我可以推送一个主分支,但它可能不会阻止人们只抓取开发分支。

Git-flow 不尝试创建一个新的流可能是正确的。 但与其失败,不如问我? “你是要我创建一个新的分支还是我帮你跟踪远程主?”

想法?

对于这里的某些人来说,没有远程主服务器,因为他们认为推送空分支是错误的。 对他们进行表演会很有用

git push --all origin 

最初推动开发和主分支以解决该部分问题。

如果有远程主机,那么在那时提出这个问题会很有用,并且对于某人来说实施起来应该不会太难。 这是一个简单的回退,如果他们自己创建主分支,不会影响其他任何人的工作流程。

这是我们遇到问题的方式。 我们现在在 git repo 中的大部分开发都在开发的功能分支上。

我已将“develop”设置为 github 上存储库的默认分支。 我想在新机器的功能分支上工作。 我克隆了 repo,做了“git flow init”,但失败了。

@lorin这表明有很多方法可以让我们被它咬住。 让 git-flow 处理这种情况对我来说很有意义,即使它需要一个烦人的提示,它仍然比根本不工作并依靠人们自己解决要好。

这个问题的一部分可能是当您运行 git clone 时 git 可能只获取单个分支,并且如果您将 GitHub 默认分支设置为 master 以外的其他分支,就像我自己所做的那样,那么 master 将不会在那里一个远程引用,直到你运行 git fetch origin (我认为)。 如果很多人都是这种情况,那么在检查是否存在之前,可能需要扩展为 git-flow-init 添加更改以支持检查 remotes/origin/master [1] 的提交以添加“git fetch origin”调用主人存在。

[1] https://github.com/nvie/gitflow/commit/baf163e07d579bec3dd0e21d00297832e8848b8b

那么在您运行 git fetch origin (我认为)之前, master 将不会作为远程引用存在。

git clone 操作从字面上克隆存储库,如progit boot 中所述,您可以断开网络连接并执行以下操作:

git checkout -b master origin/master

git 将为您创建名为 master 的本地分支作为 origin/master 的副本。

笔记:

git checkout master

就好像没有找到分支但有一个跟踪分支被使用就足够了。

@kasterma谢谢!

$ git flow init

Which branch should be used for bringing forth production releases?
   - develop
Branch name for production releases: [] 
Local branch '' does not exist.

$ git branch -a
* develop
  remotes/origin/HEAD -> origin/develop
  remotes/origin/develop
  remotes/origin/master

要获取本地分支:

$ git checkout master
$ git checkout develop
$ git branch -a
* develop
  master
  remotes/origin/HEAD -> origin/develop
  remotes/origin/develop
  remotes/origin/master

现在正常运行 git flow init 。

$ git flow init

git config gitflow.branch.master master 在您无法“取消” git flow init 时正确设置您的 master 分支。

同样在这里,我有同样的问题。

+1 相同的问题

+1

刚碰到这个。 嘎嘎! +1

确保在您的本地存储库中至少检出一次 master。

我会的。谢谢

2016 年 11 月 18 日下午 6:41,“Rob Moore”通知@ github.com 写道:

确保在您的本地存储库中至少检出一次 master。


您收到此消息是因为您订阅了此线程。
直接回复本邮件,在GitHub上查看
https://github.com/nvie/gitflow/issues/121#issuecomment -261593726,或者静音
线程
https://github.com/notifications/unsubscribe-auth/AVuyNjaPvHr8jyO9Zmy1bzynI0mhm0F_ks5q_eNRgaJpZM4AD0E_
.

+1 也发生在我身上。

做了以下步骤来解决克隆回购的问题

 git checkout -b master
 git checkout develop
 git flow init

我的 TeamCity CI 流程可以通过 _ant_ 脚本将构建包装在 _git 流发布_中,但我在此过程中了解到有必要同时检出masterdevelop ,然后运行默认初始化在构建之前:

git flow init -d

跟踪初始主分支不是最明智的,例如
git checkout -t origin/master

为我工作! 谢谢你

解决办法是:
-git 结账大师
-git checkout 开发
-git流初始化

@andres310597这可能就是你的答案。 它对我的回购没有帮助。

➜  mobile_provider git:(develop) git checkout master   
Updating files: 100% (17199/17199), done.
Switched to branch 'master'
Your branch is up to date with 'origin/master'. 
➜  mobile_provider git:(master) ✗ git checkout develop
Updating files: 100% (17199/17199), done.
Switched to branch 'develop'
Your branch is up to date with 'origin/develop'.                                                            /3.1s
➜  mobile_provider git:(develop) git flow init       

Which branch should be used for integration of the "next release"?
   - bug/mstelly/prov/2449-leave-job-crash
   - master
   - poc/realmdb
Branch name for "next release" development: [develop]

我的.gitconfig文件不包含对任何流设置的引用。 所以我不知道这些值存储在哪里。

这个问题已经存在 9 年了,这一事实说明我们很可能很快就会解决这个问题。 但是,我接受了默认值并收到了以下消息:
To force reinitialization, use: git flow init -f
所以,它没有坏。 我想它没有很好的记录。 有人可能应该关闭这个问题。

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

nvie picture nvie  ·  10评论

alanhogan picture alanhogan  ·  6评论

harshadyeola picture harshadyeola  ·  4评论

nvaken picture nvaken  ·  5评论

88Alex picture 88Alex  ·  17评论